Skip to content

Commit

Permalink
TEMP: Add investigation dir
Browse files Browse the repository at this point in the history
Add some example migrations to reproduce the problem.
  • Loading branch information
andrew-farries committed Jan 15, 2024
1 parent 2c6c7bb commit d14ff7d
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
42 changes: 42 additions & 0 deletions investigation/01_create_tables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "01_create_tables",
"operations": [
{
"create_table": {
"name": "employees",
"columns": [
{
"name": "id",
"type": "serial",
"pk": true
},
{
"name": "name",
"type": "varchar(255)"
},
{
"name": "department_id",
"type": "integer",
"nullable": true
}
]
}
},
{
"create_table": {
"name": "departments",
"columns": [
{
"name": "id",
"type": "serial",
"pk": true
},
{
"name": "name",
"type": "varchar(255)"
}
]
}
}
]
}
18 changes: 18 additions & 0 deletions investigation/02_add_fk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "02_add_fk",
"operations": [
{
"alter_column": {
"table": "employees",
"column": "department_id",
"references": {
"name": "fk_employees_department_id",
"table": "departments",
"column": "id"
},
"up": "''",
"down": "''"
}
}
]
}
14 changes: 14 additions & 0 deletions investigation/03_set_fk_not_null.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "03_set_fk_not_null",
"operations": [
{
"alter_column": {
"table": "employees",
"column": "department_id",
"nullable": false,
"up": "(SELECT CASE WHEN department_id IS NULL THEN 1 ELSE department_id END)",
"down": ""
}
}
]
}
2 changes: 2 additions & 0 deletions investigation/insert.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
insert into departments (name) values ('engineering'), ('marketing');
insert into employees (name, department_id) values ('alice', 1), ('bob', 2);

0 comments on commit d14ff7d

Please sign in to comment.