#5996 Apply bodhi-2.6.0 migration to staging
Closed: Fixed 7 years ago Opened 7 years ago by bowlofeggs.

Hello!

Due to the staging BDR setup and due to my lack of access, I need someone to run the following SQL script on Bodhi's staging database:

BEGIN;

SET LOCAL bdr.permit_ddl_locking = on;

-- Running upgrade 4f2f825bcf4a -> fc6b0169c596
-- Add a column for single-table inheritance to the packages table.

ALTER TABLE packages ADD COLUMN type INTEGER DEFAULT '1' NOT NULL;

ALTER TABLE packages ALTER COLUMN type DROP DEFAULT;

UPDATE alembic_version SET version_num='fc6b0169c596' WHERE alembic_version.version_num = '4f2f825bcf4a';

-- Running upgrade fc6b0169c596 -> 12d3e8695f90
-- Drop the unused inherited column from the builds table.

ALTER TABLE builds DROP COLUMN inherited;

UPDATE alembic_version SET version_num='12d3e8695f90' WHERE alembic_version.version_num = 'fc6b0169c596';

COMMIT;

Once this is done, staging should be all set with the Bodhi 2.6.0 beta (the RPMs are already installed.)


Hum, it doesn't seem like this at all:

ALTER TABLE packages ADD COLUMN type INTEGER DEFAULT '1' NOT NULL;

ERROR: ALTER TABLE ... ADD COLUMN ... DEFAULT may only affect UNLOGGED or TEMPORARY tables when BDR is active; packages is a regular table

Ugh. It's painful that alembic doesn't support BDR ☹

I guess I'll need to do an update query to set all the records to 1 and then set the field to be non-nullable.

OK, I haven't actually tried this on a db (but it's pretty easy to reset the stg db and this is only for stg…), but here's my attempt at working around the BDR restrictions:

BEGIN;

SET LOCAL bdr.permit_ddl_locking = on;

-- Running upgrade 4f2f825bcf4a -> fc6b0169c596
-- Add a column for single-table inheritance to the packages table.

ALTER TABLE packages ADD COLUMN type INTEGER;

UPDATE packages SET type=1;

ALTER TABLE packages ALTER COLUMN type SET NOT NULL;

UPDATE alembic_version SET version_num='fc6b0169c596' WHERE alembic_version.version_num = '4f2f825bcf4a';

-- Running upgrade fc6b0169c596 -> 12d3e8695f90
-- Drop the unused inherited column from the builds table.

ALTER TABLE builds DROP COLUMN inherited;

UPDATE alembic_version SET version_num='12d3e8695f90' WHERE alembic_version.version_num = 'fc6b0169c596';

COMMIT;

That worked. ;)

:e-mail:

Metadata Update from @kevin:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

7 years ago

Login to comment on this ticket.

Metadata