album/migrations/20160808022325_create_cameras_table/up.sql

10 lines
267 B
MySQL
Raw Normal View History

CREATE TABLE cameras (
id SERIAL PRIMARY KEY,
manufacturer VARCHAR NOT NULL,
model VARCHAR NOT NULL
);
CREATE UNIQUE INDEX cameras_idx ON cameras (manufacturer, model);
ALTER TABLE photos ADD COLUMN camera_id INTEGER REFERENCES cameras (id);