34968-vm/migrations/20251015_create_cuisines_tables.sql
Flatlogic Bot c3d7232b7a V10
2025-10-15 04:10:46 +00:00

21 lines
568 B
SQL

-- Create cuisines table
CREATE TABLE IF NOT EXISTS cuisines (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL UNIQUE
);
-- Create restaurant_cuisines linking table for many-to-many relationship
CREATE TABLE IF NOT EXISTS restaurant_cuisines (
restaurant_id INT NOT NULL,
cuisine_id INT NOT NULL,
PRIMARY KEY (restaurant_id, cuisine_id),
CONSTRAINT fk_restaurant
FOREIGN KEY(restaurant_id)
REFERENCES restaurants(id)
ON DELETE CASCADE,
CONSTRAINT fk_cuisine
FOREIGN KEY(cuisine_id)
REFERENCES cuisines(id)
ON DELETE CASCADE
);