TypeScript
[
{
"id": "schema.public",
"label": "Create schema \"public\"",
"operationClass": "additive",
"target": {
"id": "postgres"
},
"precheck": [],
"execute": [
{
"description": "Create schema \"public\"",
"sql": "CREATE SCHEMA IF NOT EXISTS \"public\"",
"params": []
}
],
"postcheck": []
},
{
"id": "table.post",
"label": "Create table \"post\"",
"summary": "Creates table \"post\"",
"operationClass": "additive",
"target": {
"id": "postgres",
"details": {
"schema": "public",
"objectType": "table",
"name": "post"
}
},
"precheck": [
{
"description": "ensure table \"post\" does not exist",
"sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"",
"params": ["\"public\".\"post\""]
}
],
"execute": [
{
"description": "create table \"post\"",
"sql": "CREATE TABLE \"public\".\"post\" (\n \"createdAt\" timestamptz DEFAULT (now()) NOT NULL,\n \"excerpt\" text NOT NULL,\n \"id\" text NOT NULL,\n \"title\" text NOT NULL,\n \"userId\" text NOT NULL,\n PRIMARY KEY (\"id\")\n)",
"params": []
}
],
"postcheck": [
{
"description": "verify table \"post\" exists",
"sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"",
"params": ["\"public\".\"post\""]
}
]
},
{
"id": "table.user",
"label": "Create table \"user\"",
"summary": "Creates table \"user\"",
"operationClass": "additive",
"target": {
"id": "postgres",
"details": {
"schema": "public",
"objectType": "table",
"name": "user"
}
},
"precheck": [
{
"description": "ensure table \"user\" does not exist",
"sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"",
"params": ["\"public\".\"user\""]
}
],
"execute": [
{
"description": "create table \"user\"",
"sql": "CREATE TABLE \"public\".\"user\" (\n \"createdAt\" timestamptz DEFAULT (now()) NOT NULL,\n \"email\" text NOT NULL,\n \"id\" text NOT NULL,\n \"name\" text NOT NULL,\n PRIMARY KEY (\"id\")\n)",
"params": []
}
],
"postcheck": [
{
"description": "verify table \"user\" exists",
"sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"",
"params": ["\"public\".\"user\""]
}
]
},
{
"id": "index.post.post_userId_idx_a489d58a",
"label": "Create index \"post_userId_idx_a489d58a\" on \"post\"",
"operationClass": "additive",
"target": {
"id": "postgres",
"details": {
"schema": "public",
"objectType": "index",
"name": "post_userId_idx_a489d58a",
"table": "post"
}
},
"precheck": [
{
"description": "ensure index \"post_userId_idx_a489d58a\" does not exist",
"sql": "SELECT (to_regclass($1)) IS NULL AS \"result\"",
"params": ["\"public\".\"post_userId_idx_a489d58a\""]
}
],
"execute": [
{
"description": "create index \"post_userId_idx_a489d58a\"",
"sql": "CREATE INDEX \"post_userId_idx_a489d58a\" ON \"public\".\"post\" (\"userId\")",
"params": []
}
],
"postcheck": [
{
"description": "verify index \"post_userId_idx_a489d58a\" exists",
"sql": "SELECT (to_regclass($1)) IS NOT NULL AS \"result\"",
"params": ["\"public\".\"post_userId_idx_a489d58a\""]
}
]
},
{
"id": "foreignKey.post.post_userId_fkey",
"label": "Add foreign key \"post_userId_fkey\" on \"post\"",
"operationClass": "additive",
"target": {
"id": "postgres",
"details": {
"schema": "public",
"objectType": "foreignKey",
"name": "post_userId_fkey",
"table": "post"
}
},
"precheck": [
{
"description": "ensure FK \"post_userId_fkey\" does not exist",
"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\"",
"params": ["post_userId_fkey", "public", "\"public\".\"post\""]
}
],
"execute": [
{
"description": "add FK \"post_userId_fkey\"",
"sql": "ALTER TABLE \"public\".\"post\"\nADD CONSTRAINT \"post_userId_fkey\"\nFOREIGN KEY (\"userId\")\nREFERENCES \"public\".\"user\" (\"id\")"
}
],
"postcheck": [
{
"description": "verify FK \"post_userId_fkey\" exists",
"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\"",
"params": ["post_userId_fkey", "public", "\"public\".\"post\""]
}
]
}
]