album/migrations/20160630103050_create_people_tables/up.sql

15 lines
397 B
MySQL
Raw Normal View History

2016-06-30 13:15:07 +03:00
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)
);