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": [
37 "\"public\".\"Post\""
38 ]
39 }
40 ],
41 "execute": [
42 {
43 "description": "create table \"Post\"",
44 "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)",
45 "params": []
46 }
47 ],
48 "postcheck": [
49 {
50 "description": "verify table \"Post\" exists",
51 "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"",
52 "params": [
53 "\"public\".\"Post\""
54 ]
55 }
56 ]
57 },
58 {
59 "id": "table.User",
60 "label": "Create table \"User\"",
61 "summary": "Creates table \"User\"",
62 "operationClass": "additive",
63 "target": {
64 "id": "postgres",
65 "details": {
66 "schema": "public",
67 "objectType": "table",
68 "name": "User"
69 }
70 },
71 "precheck": [
72 {
73 "description": "ensure table \"User\" does not exist",
74 "sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"",
75 "params": [
76 "\"public\".\"User\""
77 ]
78 }
79 ],
80 "execute": [
81 {
82 "description": "create table \"User\"",
83 "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)",
84 "params": []
85 }
86 ],
87 "postcheck": [
88 {
89 "description": "verify table \"User\" exists",
90 "sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"",
91 "params": [
92 "\"public\".\"User\""
93 ]
94 }
95 ]
96 },
97 {
98 "id": "unique.User.User_email_key",
99 "label": "Add unique constraint on \"User\" (email)",
100 "operationClass": "additive",
101 "target": {
102 "id": "postgres",
103 "details": {
104 "schema": "public",
105 "objectType": "unique",
106 "name": "User_email_key",
107 "table": "User"
108 }
109 },
110 "precheck": [
111 {
112 "description": "ensure constraint \"User_email_key\" does not exist",
113 "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\"",
114 "params": [
115 "User_email_key",
116 "public",
117 "\"public\".\"User\""
118 ]
119 }
120 ],
121 "execute": [
122 {
123 "description": "add unique constraint \"User_email_key\"",
124 "sql": "ALTER TABLE \"public\".\"User\" ADD CONSTRAINT \"User_email_key\" UNIQUE (\"email\")"
125 }
126 ],
127 "postcheck": [
128 {
129 "description": "verify constraint \"User_email_key\" exists",
130 "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\"",
131 "params": [
132 "User_email_key",
133 "public",
134 "\"public\".\"User\""
135 ]
136 }
137 ]
138 }
139]