18 lines
660 B
SQL
18 lines
660 B
SQL
-- migrate:up
|
|
|
|
-- The fleet mixes two frame sizes and the reservation form asks for one of
|
|
-- them, so the size is an attribute of the bike rather than something guessed
|
|
-- from its name.
|
|
CREATE TYPE bike_size AS ENUM ('large', 'small');
|
|
|
|
ALTER TABLE bikes ADD COLUMN "size" bike_size NOT NULL DEFAULT 'small';
|
|
|
|
-- The current fleet: 1000 and 2000 are the large ones, 3000/4000/5000 the small
|
|
UPDATE bikes SET "size" = 'large' WHERE "name" IN ('1000', '2000');
|
|
|
|
-- Every bike must state its size, so no value is implied from now on
|
|
ALTER TABLE bikes ALTER COLUMN "size" DROP DEFAULT;
|
|
|
|
-- migrate:down
|
|
ALTER TABLE bikes DROP COLUMN "size";
|
|
DROP TYPE bike_size;
|