From ad0837689ae2d55f046704cf42c937f0d9b7fd2c Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 12 Feb 2023 21:55:03 +0800 Subject: [PATCH] chore: add upgrader for #40 --- db/app_uoj233.sql | 3 +- web/app/upgrade/40_contest_resources/up.sql | 1 + .../upgrade/40_contest_resources/upgrade.php | 37 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 web/app/upgrade/40_contest_resources/up.sql create mode 100644 web/app/upgrade/40_contest_resources/upgrade.php diff --git a/db/app_uoj233.sql b/db/app_uoj233.sql index 806f345..1d2c42f 100644 --- a/db/app_uoj233.sql +++ b/db/app_uoj233.sql @@ -995,7 +995,8 @@ INSERT INTO `upgrades` (`name`, `status`, `updated_at`) VALUES ('21_problem_difficulty', 'up', now()), ('28_remote_judge', 'up', now()), ('31_problem_resources', 'up', now()), - ('36_decimal_score_range', 'up', now()); + ('36_decimal_score_range', 'up', now()), + ('40_contest_resources', 'up', now()); /*!40000 ALTER TABLE `upgrades` ENABLE KEYS */; UNLOCK TABLES; diff --git a/web/app/upgrade/40_contest_resources/up.sql b/web/app/upgrade/40_contest_resources/up.sql new file mode 100644 index 0000000..760bfc3 --- /dev/null +++ b/web/app/upgrade/40_contest_resources/up.sql @@ -0,0 +1 @@ +ALTER TABLE `contests` MODIFY `extra_config` json NOT NULL; diff --git a/web/app/upgrade/40_contest_resources/upgrade.php b/web/app/upgrade/40_contest_resources/upgrade.php new file mode 100644 index 0000000..6d51321 --- /dev/null +++ b/web/app/upgrade/40_contest_resources/upgrade.php @@ -0,0 +1,37 @@ + $link[0], + 'url' => '/blogs/' . $link[1], + ]; + } + + $extra_config['links'] = $new_links; + } + + DB::update([ + "update contests", + "set", [ + "extra_config" => json_encode($extra_config, JSON_FORCE_OBJECT), + ], + "where", [ + "id" => $contest['id'], + ], + ]); + } + } +};