-- P5-4025 add room type

CREATE TABLE room_types
(
  id SERIAL PRIMARY KEY,
  name VARCHAR,
  UNIQUE(name)
);


ALTER TABLE rooms ADD COLUMN room_type_id INTEGER;


ALTER TABLE rooms
    ADD CONSTRAINT room_type_id_fkey
    FOREIGN KEY (room_type_id)
    REFERENCES room_types(id) MATCH SIMPLE;


INSERT INTO room_types (name) VALUES
    ('dining-room'), --1
    ('living-room'), --2
    ('kids-room'), --3
    ('bedroom'), --4
    ('office'), --5
    ('baby-room'), --6
    ('hallway'); --7


UPDATE rooms SET room_type_id = 1 WHERE name LIKE 'room01%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room02%';
UPDATE rooms SET room_type_id = 3 WHERE name LIKE 'room03%';
UPDATE rooms SET room_type_id = 4 WHERE name LIKE 'room04%';
UPDATE rooms SET room_type_id = 5 WHERE name LIKE 'room05%';
UPDATE rooms SET room_type_id = 6 WHERE name LIKE 'room06%';
UPDATE rooms SET room_type_id = 3 WHERE name LIKE 'room07%';
UPDATE rooms SET room_type_id = 1 WHERE name LIKE 'room08%';
UPDATE rooms SET room_type_id = 7 WHERE name LIKE 'room09%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room10%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room11%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room12%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room13%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room14%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room15%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room16%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room17%';
UPDATE rooms SET room_type_id = 3 WHERE name LIKE 'room18%';
UPDATE rooms SET room_type_id = 5 WHERE name LIKE 'room19%';
UPDATE rooms SET room_type_id = 4 WHERE name LIKE 'room20%';
UPDATE rooms SET room_type_id = 5 WHERE name LIKE 'room21%';
UPDATE rooms SET room_type_id = 4 WHERE name LIKE 'room22%';
UPDATE rooms SET room_type_id = 3 WHERE name LIKE 'room23%';
UPDATE rooms SET room_type_id = 1 WHERE name LIKE 'room24%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room25%';
UPDATE rooms SET room_type_id = 5 WHERE name LIKE 'room26%';
UPDATE rooms SET room_type_id = 7 WHERE name LIKE 'room27%';
UPDATE rooms SET room_type_id = 1 WHERE name LIKE 'room28%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room29%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room30%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room31%';
UPDATE rooms SET room_type_id = 2 WHERE name LIKE 'room32%';

