Skip to content

Commit 4b62240

Browse files
committed
Add feed table and drop statements to show reverse drop
- Added another table for the example to show how to drop tables in reverse order at beginning of first save of the file. - Battle tested (meaning, a new docker image and everything from scrath ran through) - lower cased everything as it is in 000.sql commited (and also to be SQL 2020 compliant ) >D
1 parent 243bf8c commit 4b62240

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

@app/db/migrations/current.sql

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,42 @@ example of a table that could be created after setup complete
55
66
- uncomment the statements below
77
- save the file and graphile-migrate will update the schema into database automagically
8+
- any "drop" statements should be at the top (in reverse order)
89
*/
910

10-
-- CREATE TYPE app_public.post_topic AS enum (
11+
-- drop table if exists feed;
12+
-- drop table if exists post;
13+
14+
-- create type app_public.post_topic as enum (
1115
-- 'discussion',
1216
-- 'inspiration',
1317
-- 'help',
1418
-- 'showcase'
1519
-- );
1620

17-
-- CREATE TABLE IF NOT EXISTS app_public.post (
18-
-- id SERIAL PRIMARY KEY,
19-
-- author_id INTEGER NOT NULL REFERENCES app_public.users(id),
20-
-- headline TEXT NOT NULL CHECK (char_length(headline) < 280),
21-
-- body TEXT,
21+
-- create table if not exists app_public.post (
22+
-- id serial primary key,
23+
-- author_id integer not null references app_public.users(id),
24+
-- headline text not null check (char_length(headline) < 280),
25+
-- body text,
2226
-- topic app_public.post_topic,
23-
-- created_at TIMESTAMP default NOW()
27+
-- created_at timestamp default now()
28+
-- );
29+
30+
-- comment on table app_public.post is 'a forum post written by a user.';
31+
-- comment on column app_public.post.id is 'the primary key for the post.';
32+
-- comment on column app_public.post.headline is 'the title written by the user.';
33+
-- comment on column app_public.post.author_id is 'the id of the author user.';
34+
-- comment on column app_public.post.topic is 'the topic this has been posted in.';
35+
-- comment on column app_public.post.body is 'the main body text of our post.';
36+
-- comment on column app_public.post.created_at is 'the time this post was created.';
37+
38+
-- create table if not exists app_public.feed (
39+
-- id serial primary key,
40+
-- posts integer not null references app_public.post(id),
41+
-- created_at timestamp default now()
2442
-- );
2543

26-
-- COMMENT ON TABLE APP_PUBLIC.POST IS 'A forum post written by a user.';
27-
-- COMMENT ON COLUMN APP_PUBLIC.POST.ID IS 'The primary key for the post.';
28-
-- COMMENT ON COLUMN APP_PUBLIC.POST.HEADLINE IS 'The title written by the user.';
29-
-- COMMENT ON COLUMN APP_PUBLIC.POST.AUTHOR_ID IS 'The id of the author user.';
30-
-- COMMENT ON COLUMN APP_PUBLIC.POST.TOPIC IS 'The topic this has been posted in.';
31-
-- COMMENT ON COLUMN APP_PUBLIC.POST.BODY IS 'The main body text of our post.';
32-
-- COMMENT ON COLUMN APP_PUBLIC.POST.CREATED_AT IS 'The time this post was created.';
44+
-- comment on table app_public.feed is 'the feed of the posts';
45+
-- comment on column app_public.feed.id is 'the primary key for the feed.';
46+
-- comment on column app_public.feed.created_at is 'the time this feed was created.';

0 commit comments

Comments
 (0)