| 1 | [ |
| 2 | { |
| 3 | "id": "table.post", |
| 4 | "label": "Create table \"post\"", |
| 5 | "summary": "Creates table \"post\"", |
| 6 | "operationClass": "additive", |
| 7 | "target": { |
| 8 | "id": "postgres", |
| 9 | "details": { |
| 10 | "schema": "public", |
| 11 | "objectType": "table", |
| 12 | "name": "post" |
| 13 | } |
| 14 | }, |
| 15 | "precheck": [ |
| 16 | { |
| 17 | "description": "ensure table \"post\" does not exist", |
| 18 | "sql": "SELECT to_regclass('\"public\".\"post\"') IS NULL" |
| 19 | } |
| 20 | ], |
| 21 | "execute": [ |
| 22 | { |
| 23 | "description": "create table \"post\"", |
| 24 | "sql": "CREATE TABLE \"public\".\"post\" (\n \"createdAt\" timestamptz DEFAULT (now()) NOT NULL,\n \"excerpt\" text NOT NULL,\n \"id\" character(36) NOT NULL,\n \"title\" text NOT NULL,\n \"userId\" text NOT NULL,\n PRIMARY KEY (\"id\")\n)" |
| 25 | } |
| 26 | ], |
| 27 | "postcheck": [ |
| 28 | { |
| 29 | "description": "verify table \"post\" exists", |
| 30 | "sql": "SELECT to_regclass('\"public\".\"post\"') IS NOT NULL" |
| 31 | } |
| 32 | ] |
| 33 | }, |
| 34 | { |
| 35 | "id": "table.user", |
| 36 | "label": "Create table \"user\"", |
| 37 | "summary": "Creates table \"user\"", |
| 38 | "operationClass": "additive", |
| 39 | "target": { |
| 40 | "id": "postgres", |
| 41 | "details": { |
| 42 | "schema": "public", |
| 43 | "objectType": "table", |
| 44 | "name": "user" |
| 45 | } |
| 46 | }, |
| 47 | "precheck": [ |
| 48 | { |
| 49 | "description": "ensure table \"user\" does not exist", |
| 50 | "sql": "SELECT to_regclass('\"public\".\"user\"') IS NULL" |
| 51 | } |
| 52 | ], |
| 53 | "execute": [ |
| 54 | { |
| 55 | "description": "create table \"user\"", |
| 56 | "sql": "CREATE TABLE \"public\".\"user\" (\n \"createdAt\" timestamptz DEFAULT (now()) NOT NULL,\n \"email\" text NOT NULL,\n \"id\" character(36) NOT NULL,\n \"name\" text NOT NULL,\n PRIMARY KEY (\"id\")\n)" |
| 57 | } |
| 58 | ], |
| 59 | "postcheck": [ |
| 60 | { |
| 61 | "description": "verify table \"user\" exists", |
| 62 | "sql": "SELECT to_regclass('\"public\".\"user\"') IS NOT NULL" |
| 63 | } |
| 64 | ] |
| 65 | }, |
| 66 | { |
| 67 | "id": "index.post.post_userId_idx", |
| 68 | "label": "Create index \"post_userId_idx\" on \"post\"", |
| 69 | "operationClass": "additive", |
| 70 | "target": { |
| 71 | "id": "postgres", |
| 72 | "details": { |
| 73 | "schema": "public", |
| 74 | "objectType": "index", |
| 75 | "name": "post_userId_idx", |
| 76 | "table": "post" |
| 77 | } |
| 78 | }, |
| 79 | "precheck": [ |
| 80 | { |
| 81 | "description": "ensure index \"post_userId_idx\" does not exist", |
| 82 | "sql": "SELECT to_regclass('\"public\".\"post_userId_idx\"') IS NULL" |
| 83 | } |
| 84 | ], |
| 85 | "execute": [ |
| 86 | { |
| 87 | "description": "create index \"post_userId_idx\"", |
| 88 | "sql": "CREATE INDEX \"post_userId_idx\" ON \"public\".\"post\" (\"userId\")" |
| 89 | } |
| 90 | ], |
| 91 | "postcheck": [ |
| 92 | { |
| 93 | "description": "verify index \"post_userId_idx\" exists", |
| 94 | "sql": "SELECT to_regclass('\"public\".\"post_userId_idx\"') IS NOT NULL" |
| 95 | } |
| 96 | ] |
| 97 | }, |
| 98 | { |
| 99 | "id": "foreignKey.post.post_userId_fkey", |
| 100 | "label": "Add foreign key \"post_userId_fkey\" on \"post\"", |
| 101 | "operationClass": "additive", |
| 102 | "target": { |
| 103 | "id": "postgres", |
| 104 | "details": { |
| 105 | "schema": "public", |
| 106 | "objectType": "foreignKey", |
| 107 | "name": "post_userId_fkey", |
| 108 | "table": "post" |
| 109 | } |
| 110 | }, |
| 111 | "precheck": [ |
| 112 | { |
| 113 | "description": "ensure FK \"post_userId_fkey\" does not exist", |
| 114 | "sql": "SELECT NOT EXISTS (\n SELECT 1 FROM pg_constraint c\n JOIN pg_namespace n ON c.connamespace = n.oid\n WHERE c.conname = 'post_userId_fkey'\n AND n.nspname = 'public'\n AND c.conrelid = to_regclass('\"public\".\"post\"')\n)" |
| 115 | } |
| 116 | ], |
| 117 | "execute": [ |
| 118 | { |
| 119 | "description": "add FK \"post_userId_fkey\"", |
| 120 | "sql": "ALTER TABLE \"public\".\"post\"\nADD CONSTRAINT \"post_userId_fkey\"\nFOREIGN KEY (\"userId\")\nREFERENCES \"public\".\"user\" (\"id\")" |
| 121 | } |
| 122 | ], |
| 123 | "postcheck": [ |
| 124 | { |
| 125 | "description": "verify FK \"post_userId_fkey\" exists", |
| 126 | "sql": "SELECT EXISTS (\n SELECT 1 FROM pg_constraint c\n JOIN pg_namespace n ON c.connamespace = n.oid\n WHERE c.conname = 'post_userId_fkey'\n AND n.nspname = 'public'\n AND c.conrelid = to_regclass('\"public\".\"post\"')\n)" |
| 127 | } |
| 128 | ] |
| 129 | } |
| 130 | ] |