You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During testing pgroll with ORMs, I read SQL statements from migrations files. sql2pgroll package can transform a single SQL operation into a pgroll migration (if implemented). So each SQL statement in a migration file was translated individually. However, there are migration file where multiple statements can be translated into a single pgroll migrations.
The example below adds a new column to an existing table, and sets a backfill value. At the moment pgroll translates this into an add_column operation, and expects the user to edit the up attribute of the migration. Then the UPDATE statement is kept as a raw SQL migration.
-- AlterTableALTERTABLE"table1" ADD COLUMN "new_column"TEXT;
-- Update all rowsUPDATE"table1"SET"new_column"= gen_random_uuid() WHERE"new_column" IS NULL;
At the moment this is translated into the following migrations:
[
{
"sql": {
"up": "UPDATE \"table1\" SET \"new_column\" = gen_random_uuid() WHERE \"new_column\" IS NULL"
}
}
]
This behaviour can be improved. pgroll could read the whole migration file, and find the appropriate up migration in the file. This could reduce the friction of converting ORM migrations to pgroll migrations.
Improved output where up migration is included in the operation:
During testing
pgroll
with ORMs, I read SQL statements from migrations files.sql2pgroll
package can transform a single SQL operation into apgroll
migration (if implemented). So each SQL statement in a migration file was translated individually. However, there are migration file where multiple statements can be translated into a singlepgroll
migrations.The example below adds a new column to an existing table, and sets a backfill value. At the moment
pgroll
translates this into anadd_column
operation, and expects the user to edit theup
attribute of the migration. Then theUPDATE
statement is kept as a raw SQL migration.At the moment this is translated into the following migrations:
and
This behaviour can be improved.
pgroll
could read the whole migration file, and find the appropriateup
migration in the file. This could reduce the friction of converting ORM migrations topgroll
migrations.Improved output where
up
migration is included in the operation:The text was updated successfully, but these errors were encountered: