~huyngo/gh-migrate

bb41aed7a78599b5424fe0f19435a66505af3228 — Ngô Ngọc Đức Huy 5 months ago 68741f9 main
Add DB schema
1 files changed, 53 insertions(+), 0 deletions(-)

A schema.sql
A schema.sql => schema.sql +53 -0
@@ 0,0 1,53 @@
DROP TABLE IF EXISTS issues;
DROP TABLE IF EXISTS comments;
DROP TABLE IF EXISTS labels;
DROP TABLE IF EXISTS labelings;
DROP TABLE IF EXISTS migrations;

CREATE TABLE issues (
	id INT PRIMARY KEY,
	title TEXT,
	github_ref INT UNIQUE,
	author TEXT,
	created_at TEXT,
	body TEXT,
	is_pull INT
);

CREATE TABLE comments (
	id INT PRIMARY KEY,
	author TEXT,
	created_at TEXT,
	body TEXT,
	issue_id INT,
	FOREIGN KEY(issue_id) REFERENCES issues(id)
);

CREATE TABLE labels (
	id INT PRIMARY KEY,
	name TEXT UNIQUE
);

CREATE TABLE labelings (
	label_id INT,
	issue_id INT,
	is_pull INT,
	FOREIGN KEY(issue_id) REFERENCES issues(id),
	FOREIGN KEY(label_id) REFERENCES labels(id)
);

CREATE TABLE targets (
	id INT,
	forge_url TEXT,
	user TEXT,
	repo TEXT
)

CREATE TABLE migrations (
	id INT PRIMARY KEY,
	table_name TEXT,
	row_id INT,
	target_id INT,
	ref INT, -- for issues/pulls
	FOREIGN KEY(target_id) REFERENCES targets(id)
);