From 33ce890c070067a506460079ea1641b5e0bd195e Mon Sep 17 00:00:00 2001 From: themohooks <81331307+themohooks@users.noreply.github.com> Date: Tue, 11 Feb 2025 20:51:14 +0300 Subject: [PATCH] Create sql_0002.sql --- sqlcore/sql_0002.sql | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sqlcore/sql_0002.sql diff --git a/sqlcore/sql_0002.sql b/sqlcore/sql_0002.sql new file mode 100644 index 0000000..3754db9 --- /dev/null +++ b/sqlcore/sql_0002.sql @@ -0,0 +1,41 @@ +-- Migration script to update database schema + +-- Drop tables that are no longer needed +-- (No tables to drop as all tables in 111.sql exist in 222.sql) + +-- Add new tables from 222.sql that don't exist in 111.sql +CREATE TABLE IF NOT EXISTS `contests` ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `themeid` int(10) NOT NULL, + `opendate` int(100) NOT NULL, + `closedate` int(10) NOT NULL, + `status` int(10) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `geodb` ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `title` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `servicekeys` ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `token` text NOT NULL, + `type` text NOT NULL, + `status` int(10) NOT NULL, + `content` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- Modify existing tables to add new columns +ALTER TABLE `photos` + ADD COLUMN IF NOT EXISTS `pinnedcomment_id` int(10) NOT NULL DEFAULT 0 AFTER `entitydata_id`; + +-- Set AUTO_INCREMENT values for the new tables +ALTER TABLE `contests` AUTO_INCREMENT = 1; +ALTER TABLE `geodb` AUTO_INCREMENT = 1; +ALTER TABLE `servicekeys` AUTO_INCREMENT = 1; + +-- Commit the changes +COMMIT; \ No newline at end of file