juunil/migrations/2023-08-07-063249_create_posts/up.sql

21 lines
484 B
SQL

CREATE TABLE post (
id BIGINT PRIMARY KEY NOT NULL,
description TEXT NOT NULL,
posted_date DATETIME NOT NULL,
crawled_date DATETIME NOT NULL
);
CREATE TABLE image (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
post_id BIGINT NOT NULL,
url TEXT NOT NULL,
FOREIGN KEY (post_id) REFERENCES post(id)
);
CREATE TABLE video (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
post_id BIGINT NOT NULL,
url TEXT NOT NULL,
FOREIGN KEY (post_id) REFERENCES post(id)
);