1[
2 {
3 "id": "schema.public",
4 "label": "Create schema \"public\"",
5 "operationClass": "additive",
6 "target": {
7 "id": "postgres"
8 },
9 "precheck": [],
10 "execute": [
11 {
12 "description": "Create schema \"public\"",
13 "sql": "CREATE SCHEMA IF NOT EXISTS \"public\"",
14 "params": []
15 }
16 ],
17 "postcheck": []
18 },
19 {
20 "id": "table.post",
21 "label": "Create table \"post\"",
22 "summary": "Creates table \"post\"",
23 "operationClass": "additive",
24 "target": {
25 "id": "postgres",
26 "details": {
27 "schema": "public",
28 "objectType": "table",
29 "name": "post"
30 }
31 },
32 "precheck": [
33 {
34 "description": "ensure table \"post\" does not exist",
35 "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"",
36 "params": ["\"public\".\"post\""]
37 }
38 ],
39 "execute": [
40 {
41 "description": "create table \"post\"",
42 "sql": "CREATE TABLE \"public\".\"post\" (\n \"authorId\" uuid NOT NULL,\n \"id\" uuid NOT NULL,\n \"title\" text NOT NULL,\n PRIMARY KEY (\"id\")\n)",
43 "params": []
44 }
45 ],
46 "postcheck": [
47 {
48 "description": "verify table \"post\" exists",
49 "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"",
50 "params": ["\"public\".\"post\""]
51 }
52 ]
53 },
54 {
55 "id": "table.user",
56 "label": "Create table \"user\"",
57 "summary": "Creates table \"user\"",
58 "operationClass": "additive",
59 "target": {
60 "id": "postgres",
61 "details": {
62 "schema": "public",
63 "objectType": "table",
64 "name": "user"
65 }
66 },
67 "precheck": [
68 {
69 "description": "ensure table \"user\" does not exist",
70 "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"",
71 "params": ["\"public\".\"user\""]
72 }
73 ],
74 "execute": [
75 {
76 "description": "create table \"user\"",
77 "sql": "CREATE TABLE \"public\".\"user\" (\n \"createdAt\" timestamptz DEFAULT (now()) NOT NULL,\n \"email\" text NOT NULL,\n \"id\" uuid NOT NULL,\n \"name\" text NOT NULL,\n PRIMARY KEY (\"id\")\n)",
78 "params": []
79 }
80 ],
81 "postcheck": [
82 {
83 "description": "verify table \"user\" exists",
84 "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"",
85 "params": ["\"public\".\"user\""]
86 }
87 ]
88 },
89 {
90 "id": "unique.user.user_email_key",
91 "label": "Add unique constraint on \"user\" (email)",
92 "operationClass": "additive",
93 "target": {
94 "id": "postgres",
95 "details": {
96 "schema": "public",
97 "objectType": "unique",
98 "name": "user_email_key",
99 "table": "user"
100 }
101 },
102 "precheck": [
103 {
104 "description": "ensure constraint \"user_email_key\" does not exist",
105 "sql": "SELECT NOT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"",
106 "params": ["user_email_key", "public", "\"public\".\"user\""]
107 }
108 ],
109 "execute": [
110 {
111 "description": "add unique constraint \"user_email_key\"",
112 "sql": "ALTER TABLE \"public\".\"user\" ADD CONSTRAINT \"user_email_key\" UNIQUE (\"email\")"
113 }
114 ],
115 "postcheck": [
116 {
117 "description": "verify constraint \"user_email_key\" exists",
118 "sql": "SELECT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"",
119 "params": ["user_email_key", "public", "\"public\".\"user\""]
120 }
121 ]
122 },
123 {
124 "id": "index.post.post_authorId_idx_e47547ed",
125 "label": "Create index \"post_authorId_idx_e47547ed\" on \"post\"",
126 "operationClass": "additive",
127 "target": {
128 "id": "postgres",
129 "details": {
130 "schema": "public",
131 "objectType": "index",
132 "name": "post_authorId_idx_e47547ed",
133 "table": "post"
134 }
135 },
136 "precheck": [
137 {
138 "description": "ensure index \"post_authorId_idx_e47547ed\" does not exist",
139 "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"",
140 "params": ["\"public\".\"post_authorId_idx_e47547ed\""]
141 }
142 ],
143 "execute": [
144 {
145 "description": "create index \"post_authorId_idx_e47547ed\"",
146 "sql": "CREATE INDEX \"post_authorId_idx_e47547ed\" ON \"public\".\"post\" (\"authorId\")",
147 "params": []
148 }
149 ],
150 "postcheck": [
151 {
152 "description": "verify index \"post_authorId_idx_e47547ed\" exists",
153 "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"",
154 "params": ["\"public\".\"post_authorId_idx_e47547ed\""]
155 }
156 ]
157 },
158 {
159 "id": "foreignKey.post.post_authorId_fkey",
160 "label": "Add foreign key \"post_authorId_fkey\" on \"post\"",
161 "operationClass": "additive",
162 "target": {
163 "id": "postgres",
164 "details": {
165 "schema": "public",
166 "objectType": "foreignKey",
167 "name": "post_authorId_fkey",
168 "table": "post"
169 }
170 },
171 "precheck": [
172 {
173 "description": "ensure FK \"post_authorId_fkey\" does not exist",
174 "sql": "SELECT NOT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"",
175 "params": ["post_authorId_fkey", "public", "\"public\".\"post\""]
176 }
177 ],
178 "execute": [
179 {
180 "description": "add FK \"post_authorId_fkey\"",
181 "sql": "ALTER TABLE \"public\".\"post\"\nADD CONSTRAINT \"post_authorId_fkey\"\nFOREIGN KEY (\"authorId\")\nREFERENCES \"public\".\"user\" (\"id\")"
182 }
183 ],
184 "postcheck": [
185 {
186 "description": "verify FK \"post_authorId_fkey\" exists",
187 "sql": "SELECT EXISTS (SELECT 1 AS \"one\" FROM \"pg_constraint\" AS \"c\" INNER JOIN \"pg_namespace\" AS \"n\" ON \"n\".\"oid\" = \"c\".\"connamespace\" WHERE (\"c\".\"conname\" = $1 AND \"n\".\"nspname\" = $2 AND \"c\".\"conrelid\" = to_regclass($3))) AS \"result\"",
188 "params": ["post_authorId_fkey", "public", "\"public\".\"post\""]
189 }
190 ]
191 }
192]