dataall icon indicating copy to clipboard operation
dataall copied to clipboard

Add check in migration scripts to create new tables only if one doesnt already exist

Open anushka-singh opened this issue 1 year ago • 1 comments

Alembic upgrades can fail/get stuck/overwrite existing tables if we dont add a check to see the existence of table with same name already.

We can add a check like this:

if not has_table('dataset_bucket', engine):
    op.create_table(
                'dataset_bucket',)

before creating new tables in the migration script upgrade.

Reference: https://github.com/awslabs/aws-dataall/pull/848/files/06edb53d772132ede68201d5d24f9acf731cab98#r1388384179

anushka-singh avatar Nov 10 '23 03:11 anushka-singh

This is a great idea @anushka-singh, thanks for raising an issue. We will include this pattern in any nwe migration script. And if we have bandwidth we will pick it up for existing scripts

dlpzx avatar Nov 27 '23 07:11 dlpzx