album/migrations/20160630121524_create_places_tables/up.sql

15 lines
394 B
MySQL
Raw Normal View History

2016-06-30 14:16:12 +03:00
CREATE TABLE places (
id SERIAL PRIMARY KEY,
slug VARCHAR UNIQUE NOT NULL,
place_name VARCHAR UNIQUE NOT NULL
);
CREATE UNIQUE INDEX places_slug_idx ON places (slug);
CREATE UNIQUE INDEX places_name_idx ON places (place_name);
CREATE TABLE photo_places (
id SERIAL PRIMARY KEY,
photo_id INTEGER NOT NULL REFERENCES photos (id),
place_id INTEGER NOT NULL REFERENCES places (id)
);