From 13c5a05bd6252e5c0b1571e9b421de3e3e0414be Mon Sep 17 00:00:00 2001 From: Imbus Date: Tue, 28 Nov 2023 00:33:52 +0100 Subject: [PATCH] Removed sqlite migraction scripts --- server/migrations/0001_users_table.sql | 31 --------------------- server/migrations/0002_posts_table.sql | 38 -------------------------- 2 files changed, 69 deletions(-) delete mode 100644 server/migrations/0001_users_table.sql delete mode 100644 server/migrations/0002_posts_table.sql diff --git a/server/migrations/0001_users_table.sql b/server/migrations/0001_users_table.sql deleted file mode 100644 index b9ccfdb..0000000 --- a/server/migrations/0001_users_table.sql +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE - IF NOT EXISTS users ( - id INTEGER PRIMARY KEY NOT NULL, - username TEXT NOT NULL UNIQUE, - password TEXT NOT NULL, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP - ); - --- Create a trigger to set created_at and updated_at on INSERT -CREATE TRIGGER IF NOT EXISTS set_created_at AFTER INSERT ON users BEGIN -UPDATE users -SET - created_at = CURRENT_TIMESTAMP -WHERE - id = NEW.id; - -END; - --- Create a trigger to set updated_at on UPDATE -CREATE TRIGGER IF NOT EXISTS set_updated_at AFTER -UPDATE ON users BEGIN -UPDATE users -SET - updated_at = CURRENT_TIMESTAMP -WHERE - id = NEW.id; - -END; - -CREATE INDEX users_username_index ON users (username); \ No newline at end of file diff --git a/server/migrations/0002_posts_table.sql b/server/migrations/0002_posts_table.sql deleted file mode 100644 index 1b9601b..0000000 --- a/server/migrations/0002_posts_table.sql +++ /dev/null @@ -1,38 +0,0 @@ -CREATE TABLE - IF NOT EXISTS posts ( - id INTEGER PRIMARY KEY NOT NULL, - user_id INTEGER NOT NULL, - content TEXT NOT NULL, - upvotes INTEGER NOT NULL DEFAULT 0, - downvotes INTEGER NOT NULL DEFAULT 0, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - FOREIGN KEY (user_id) REFERENCES users (id) - ); - --- Create a trigger to set created_at and updated_at on INSERT -CREATE TRIGGER IF NOT EXISTS set_created_at AFTER INSERT ON posts BEGIN -UPDATE posts -SET - created_at = CURRENT_TIMESTAMP -WHERE - id = NEW.id; - -END; - --- Create a trigger to set updated_at on UPDATE -CREATE TRIGGER IF NOT EXISTS set_updated_at AFTER -UPDATE ON posts BEGIN -UPDATE posts -SET - updated_at = CURRENT_TIMESTAMP -WHERE - id = NEW.id; - -END; - -create INDEX IF NOT EXISTS posts_user_id_index ON posts (user_id); - -create INDEX IF NOT EXISTS posts_id_index ON posts (id); - -CREATE INDEX idx_created_at_desc ON posts (created_at DESC); \ No newline at end of file