album/migrations/20160630103050_create_people_tables/up.sql
2016-06-30 12:15:07 +02:00

15 lines
397 B
SQL

CREATE TABLE people (
id SERIAL PRIMARY KEY,
slug VARCHAR UNIQUE NOT NULL,
person_name VARCHAR UNIQUE NOT NULL
);
CREATE UNIQUE INDEX people_slug_idx ON people (slug);
CREATE UNIQUE INDEX people_name_idx ON people (person_name);
CREATE TABLE photo_people (
id SERIAL PRIMARY KEY,
photo_id INTEGER NOT NULL REFERENCES photos (id),
person_id INTEGER NOT NULL REFERENCES people (id)
);