pgroll
pgroll copied to clipboard
Allow to create a table with a self reference column with a single operation
Right now it's not possible to create a table referencing itself, like this:
{
"$schema": "https://raw.githubusercontent.com/xataio/pgroll/main/schema.json",
"name": "branches",
"operations": [
{
"create_table": {
"name": "users",
"columns": [
{
"name": "id",
"type": "text",
"pk": true
},
{
"name": "name",
"type": "text"
},
{
"name": "parent_id",
"type": "text",
"nullable": true,
"references": {
"name": "parent_id",
"table": "users",
"column": "id",
"on_delete": "SET NULL"
}
}
]
}
}
]
}
This is still doable by adding a new migration to include the parent_id column, but ideally this can be done in one go