adding foreign key references
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
CREATE TABLE IF NOT EXISTS "audit_log" (
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"initiated_by" Integer NOT NULL,
|
||||
"initiated_by" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"webhook_action" Boolean NOT NULL DEFAULT FALSE,
|
||||
"resource_type" Text NOT NULL,
|
||||
"resource_id" Integer NOT NULL,
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
-- CREATE TABLE "projects" ------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS "projects"(
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"creator_id" Integer NOT NULL,
|
||||
"owner_id" Integer NOT NULL,
|
||||
"creator_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"owner_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"git_repository_url" Text,
|
||||
"title" Text NOT NULL,
|
||||
"description" Text,
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
-- CREATE TABLE "project_user" ---------------------------------
|
||||
CREATE TABLE IF NOT EXISTS "project_user" (
|
||||
"project_id" Integer NOT NULL,
|
||||
"user_id" Integer NOT NULL,
|
||||
"invited_by_user_id" Integer,
|
||||
"project_id" Integer NOT NULL REFERENCES "projects"("id"),
|
||||
"user_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"invited_by_user_id" Integer REFERENCES "users"("id"),
|
||||
"role" Text NOT NULL DEFAULT 'member',
|
||||
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"deleted_at" DateTime,
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
-- CREATE TABLE "project_labels" -------------------------------
|
||||
CREATE TABLE IF NOT EXISTS "project_labels" (
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"project_id" Integer NOT NULL,
|
||||
"user_id" Integer NOT NULL,
|
||||
"project_id" Integer NOT NULL REFERENCES "projects"("id"),
|
||||
"user_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"label" Text NOT NULL,
|
||||
"color" Text NOT NULL DEFAULT '#42f5ce',
|
||||
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
-- CREATE TABLE "project_links" --------------------------------
|
||||
CREATE TABLE IF NOT EXISTS "project_links" (
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"project_id" Integer NOT NULL,
|
||||
"user_id" Integer NOT NULL,
|
||||
"project_id" Integer NOT NULL REFERENCES "projects"("id"),
|
||||
"user_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"remote_url" Text NOT NULL,
|
||||
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"deleted_at" DateTime
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
-- CREATE TABLE "project_attachments" --------------------------
|
||||
CREATE TABLE IF NOT EXISTS "project_attachments" (
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"project_id" Integer NOT NULL,
|
||||
"user_id" Integer NOT NULL,
|
||||
"project_id" Integer NOT NULL REFERENCES "projects"("id"),
|
||||
"user_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"path" TEXT NOT NULL,
|
||||
"preview_path" TEXT NOT NULL,
|
||||
"filesize" Integer NOT NULL DEFAULT 0,
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
-- CREATE TABLE "project_favorites" ----------------------------
|
||||
CREATE TABLE IF NOT EXISTS "project_favorites" (
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"project_id" Integer NOT NULL,
|
||||
"user_id" Integer NOT NULL,
|
||||
"project_id" Integer NOT NULL REFERENCES "projects"("id"),
|
||||
"user_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"favorited_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"deleted_at" DateTime,
|
||||
CONSTRAINT "idx_project_user" UNIQUE ( project_id, user_id ) );
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
-- CREATE TABLE "project_dependencies" -----------------------------
|
||||
CREATE TABLE IF NOT EXISTS "project_dependencies" (
|
||||
"source_project_id" Integer NOT NULL,
|
||||
"blocking_project_id" Integer NOT NULL,
|
||||
"source_project_id" Integer NOT NULL REFERENCES "projects"("id"),
|
||||
"blocking_project_id" Integer NOT NULL REFERENCES "projects"("id"),
|
||||
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT "idx_dependant_project" UNIQUE ( source_project_id, blocking_project_id )
|
||||
);
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
-- CREATE TABLE "issues" ---------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS "issues" (
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"creator_id" Integer NOT NULL,
|
||||
"assignee_id" Integer,
|
||||
"project_id" Integer NOT NULL,
|
||||
"creator_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"assignee_id" Integer REFERENCES "users"("id"),
|
||||
"project_id" Integer NOT NULL REFERENCES "projects"("id"),
|
||||
"project_issue_id" Integer NOT NULL,
|
||||
"title" Text,
|
||||
"description" Text,
|
||||
@@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS "issues" (
|
||||
"start_date" DateTime,
|
||||
"target_date" DateTime,
|
||||
"completed_at" DateTime,
|
||||
"parent_issue_id" Integer,
|
||||
"parent_issue_id" Integer REFERENCES "issues"("id"),
|
||||
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" DateTime,
|
||||
"deleted_at" DateTime,
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
-- CREATE TABLE "issue_labels" ---------------------------------
|
||||
CREATE TABLE IF NOT EXISTS "issue_labels" (
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"issue_id" Integer NOT NULL,
|
||||
"project_label_id" Integer NOT NULL,
|
||||
"user_id" Integer NOT NULL,
|
||||
"issue_id" Integer NOT NULL REFERENCES "issues"("id"),
|
||||
"project_label_id" Integer NOT NULL REFERENCES "project_labels"("id"),
|
||||
"user_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"deleted_at" DateTime,
|
||||
CONSTRAINT "idx_issue_labels" UNIQUE ( issue_id, project_label_id ) );
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
-- CREATE TABLE "issue_links" ----------------------------------
|
||||
CREATE TABLE IF NOT EXISTS "issue_links" (
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"issue_id" Integer NOT NULL,
|
||||
"user_id" Integer NOT NULL,
|
||||
"issue_id" Integer NOT NULL REFERENCES "issues"("id"),
|
||||
"user_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"remote_url" Text NOT NULL,
|
||||
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"deleted_at" DateTime
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
-- CREATE TABLE "issue_attachments" ----------------------------
|
||||
CREATE TABLE IF NOT EXISTS "issue_attachments" (
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"issue_id" Integer NOT NULL,
|
||||
"user_id" Integer NOT NULL,
|
||||
"issue_id" Integer NOT NULL REFERENCES "issues"("id"),
|
||||
"user_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"path" TEXT NOT NULL,
|
||||
"preview_path" TEXT NOT NULL,
|
||||
"filesize" Integer NOT NULL DEFAULT 0,
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
-- CREATE TABLE "issue_blockers" -------------------------------
|
||||
CREATE TABLE IF NOT EXISTS "issue_blockers" (
|
||||
"source_issue_id" Integer NOT NULL,
|
||||
"blocking_issue_id" Integer NOT NULL,
|
||||
"source_issue_id" Integer NOT NULL REFERENCES "issues"("id"),
|
||||
"blocking_issue_id" Integer NOT NULL REFERENCES "issues"("id"),
|
||||
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT "idx_blocking_issue" UNIQUE ( source_issue_id, blocking_issue_id )
|
||||
);
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
-- CREATE TABLE "issue_comments" -------------------------------
|
||||
CREATE TABLE IF NOT EXISTS "issue_comments" (
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"issue_id" Integer NOT NULL,
|
||||
"user_id" Integer NOT NULL,
|
||||
"issue_id" Integer NOT NULL REFERENCES "issues"("id"),
|
||||
"user_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"body" TEXT NOT NULL,
|
||||
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" DateTime,
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
-- CREATE TABLE "issue_comment_links" --------------------------
|
||||
CREATE TABLE IF NOT EXISTS "issue_comment_links" (
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"issue_comment_id" Integer NOT NULL,
|
||||
"user_id" Integer NOT NULL,
|
||||
"issue_comment_id" Integer NOT NULL REFERENCES "issue_comments"("id"),
|
||||
"user_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"remote_url" Text NOT NULL,
|
||||
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"deleted_at" DateTime
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
-- CREATE TABLE "issue_comment_attachments" --------------------------
|
||||
CREATE TABLE IF NOT EXISTS "issue_comment_attachments" (
|
||||
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"issue_comment_id" Integer NOT NULL,
|
||||
"user_id" Integer NOT NULL,
|
||||
"issue_comment_id" Integer NOT NULL REFERENCES "issue_comments"("id"),
|
||||
"user_id" Integer NOT NULL REFERENCES "users"("id"),
|
||||
"path" TEXT NOT NULL,
|
||||
"preview_path" TEXT NOT NULL,
|
||||
"filesize" Integer NOT NULL DEFAULT 0,
|
||||
|
||||
Reference in New Issue
Block a user