|
| 1 | +CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" ( |
| 2 | + migration_id character varying(150) NOT NULL, |
| 3 | + product_version character varying(32) NOT NULL, |
| 4 | + CONSTRAINT pk___ef_migrations_history PRIMARY KEY (migration_id) |
| 5 | +); |
| 6 | + |
| 7 | +START TRANSACTION; |
| 8 | + |
| 9 | +CREATE TABLE threads ( |
| 10 | + id integer GENERATED BY DEFAULT AS IDENTITY, |
| 11 | + thread jsonb NULL, |
| 12 | + board jsonb NULL, |
| 13 | + is_pinned boolean NOT NULL, |
| 14 | + is_locked boolean NOT NULL, |
| 15 | + is_deleted boolean NOT NULL, |
| 16 | + type integer NOT NULL, |
| 17 | + last_post_no integer NOT NULL, |
| 18 | + last_post_page integer NOT NULL, |
| 19 | + created timestamp with time zone NOT NULL, |
| 20 | + total_posts integer NOT NULL, |
| 21 | + total_view integer NOT NULL, |
| 22 | + creator jsonb NULL, |
| 23 | + comments integer[] NULL, |
| 24 | + CONSTRAINT pk_threads PRIMARY KEY (id) |
| 25 | +); |
| 26 | + |
| 27 | +INSERT INTO "__EFMigrationsHistory" (migration_id, product_version) |
| 28 | +VALUES ('20230422112523_Initial', '7.0.3'); |
| 29 | + |
| 30 | +COMMIT; |
| 31 | + |
| 32 | +START TRANSACTION; |
| 33 | + |
| 34 | +ALTER TABLE threads RENAME COLUMN comments TO posts; |
| 35 | + |
| 36 | +INSERT INTO "__EFMigrationsHistory" (migration_id, product_version) |
| 37 | +VALUES ('20230426200040_minor change in thread schema', '7.0.3'); |
| 38 | + |
| 39 | +COMMIT; |
| 40 | + |
| 41 | +START TRANSACTION; |
| 42 | + |
| 43 | +ALTER TABLE threads DROP COLUMN posts; |
| 44 | + |
| 45 | +CREATE TABLE posts ( |
| 46 | + id text NOT NULL, |
| 47 | + is_comment boolean NOT NULL, |
| 48 | + is_deleted boolean NOT NULL, |
| 49 | + is_mod_comment boolean NOT NULL, |
| 50 | + post_no integer NOT NULL, |
| 51 | + creator jsonb NULL, |
| 52 | + is_edited boolean NOT NULL, |
| 53 | + created timestamp with time zone NOT NULL, |
| 54 | + content text NULL, |
| 55 | + thread_id integer NOT NULL, |
| 56 | + CONSTRAINT pk_posts PRIMARY KEY (id), |
| 57 | + CONSTRAINT fk_posts_threads_thread_id FOREIGN KEY (thread_id) REFERENCES threads (id) ON DELETE CASCADE |
| 58 | +); |
| 59 | + |
| 60 | +CREATE INDEX ix_posts_thread_id ON posts (thread_id); |
| 61 | + |
| 62 | +INSERT INTO "__EFMigrationsHistory" (migration_id, product_version) |
| 63 | +VALUES ('20230427121144_add post entity', '7.0.3'); |
| 64 | + |
| 65 | +COMMIT; |
| 66 | + |
| 67 | +START TRANSACTION; |
| 68 | + |
| 69 | +INSERT INTO "__EFMigrationsHistory" (migration_id, product_version) |
| 70 | +VALUES ('20230428153019_idk', '7.0.3'); |
| 71 | + |
| 72 | +COMMIT; |
| 73 | + |
| 74 | +START TRANSACTION; |
| 75 | + |
| 76 | +INSERT INTO "__EFMigrationsHistory" (migration_id, product_version) |
| 77 | +VALUES ('20230516162526_stopped using settings.json', '7.0.3'); |
| 78 | + |
| 79 | +COMMIT; |
| 80 | + |
| 81 | +START TRANSACTION; |
| 82 | + |
| 83 | +CREATE INDEX ix_threads_created ON threads (created DESC); |
| 84 | + |
| 85 | +CREATE INDEX ix_posts_created ON posts (created DESC); |
| 86 | + |
| 87 | +INSERT INTO "__EFMigrationsHistory" (migration_id, product_version) |
| 88 | +VALUES ('20241223211333_index on thread.created and post.created', '7.0.3'); |
| 89 | + |
| 90 | +COMMIT; |
| 91 | + |
| 92 | +START TRANSACTION; |
| 93 | + |
| 94 | +CREATE INDEX ix_posts_creator_text ON posts ((creator->>'Text')); |
| 95 | + |
| 96 | +CREATE INDEX ix_threads_creator_text ON threads ((creator->>'Text')); |
| 97 | + |
| 98 | +INSERT INTO "__EFMigrationsHistory" (migration_id, product_version) |
| 99 | +VALUES ('20241223213958_index on thread.creator.text and post.creator.text', '7.0.3'); |
| 100 | + |
| 101 | +COMMIT; |
| 102 | + |
0 commit comments