wipe it clean

This commit is contained in:
2026-08-12 14:15:12 -06:00
parent d14488d2f2
commit ab6b5be3de
120 changed files with 2 additions and 13085 deletions
Binary file not shown.
-35
View File
@@ -1,35 +0,0 @@
package db
import (
"database/sql",
"log"
"github.com/golang-migrate/migrate/v4"
"github.com/golang-migrate/migrate/v4/database/sqlite3"
_ "github.com/golang-migrate/migrate/v4/source/file"
_ "github.com/mattn/go-sqlite3"
)
func main() {
db, err := sql.Open("sqlite3", "database.sqlite")
if err != nil {
log.Fatal(err)
}
defer db.Close()
driver, err := sqlite3.WithInstance(db, &sqlite3.Config{})
if err != nil {
log.Fatal(err)
}
migrator, err := migrate.NewWithDatabaseInstance(
"file://migrations/", "sqlite3", driver
)
if err != nil {
log.Fatal(err)
}
if err := migrator.Up(); err != nill && err != migrate.ErrNoChange {
log.Fatal(err)
}
}
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_00_00_000000_create_audit_log_table.sql.down.sql
-- DROP TABLE "audit_log" --------------------------------------
DROP TABLE IF EXISTS "audit_log";
-- -------------------------------------------------------------
@@ -1,34 +0,0 @@
-- internal/db/migrations/2026_00_00_000000_create_audit_log_table.sql.up.sql
-- CREATE TABLE "audit_log" ------------------------------------
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 REFERENCES "users"("id"),
"webhook_action" Boolean NOT NULL DEFAULT FALSE,
"resource_type" Text NOT NULL,
"resource_id" Integer NOT NULL,
"action_type" Text NOT NULL,
"summary" Text,
"previous_values" Text,
"new_values" Text
);
-- -------------------------------------------------------------
-- CREATE INDEX "idx_audit_resource" ---------------------------
CREATE INDEX IF NOT EXISTS "idx_audit_resource"
ON "audit_log" ( "resource_type", "resource_id" )
;
-- -------------------------------------------------------------
-- CREATE INDEX "idx_audit_initiator" --------------------------
CREATE INDEX IF NOT EXISTS "idx_audit_initiator"
ON "audit_log" ( "initiated_by", "created_at" )
;
-- -------------------------------------------------------------
-- CREATE INDEX "idx_audit_created" ----------------------------
CREATE INDEX IF NOT EXISTS "idx_audit_created"
ON "audit_log" ( "created_at" )
;
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000000_create_users_table.sql.down.sql
-- DROP TABLE "users" ------------------------------------------
DROP TABLE IF EXISTS "users";
-- -------------------------------------------------------------
@@ -1,43 +0,0 @@
-- internal/db/migrations/2026_01_01_000000_create_users_table.sql.up.sql
-- CREATE TABLE "users" ----------------------------------------
CREATE TABLE IF NOT EXISTS "users" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"username" Text NOT NULL,
"is_admin" Boolean DEFAULT FALSE,
"name" Text NOT NULL,
"email" Text NOT NULL,
"password" Text,
"avatar_url" Text,
"provider" Text NOT NULL DEFAULT 'local',
"provider_id" Text,
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DateTime,
"deleted_at" DateTime,
CONSTRAINT "unique_username" UNIQUE ( username ),
CONSTRAINT "unique_email" UNIQUE ( email )
);
-- -------------------------------------------------------------
-- CREATE INDEX "idx_users_provider" ---------------------------
CREATE UNIQUE INDEX IF NOT EXISTS "idx_users_provider"
ON "users"( "provider", "provider_id" )
WHERE "provider_id" IS NOT NULL
;
-- -------------------------------------------------------------
-- INSERT "SYSTEM" USER ----------------------------------------
INSERT INTO users
(username,is_admin,name,email,avatar_url)
VALUES
('system', true, 'System User', 'system@localhost', '/uploads/avatars/system.png')
;
-- -------------------------------------------------------------
-- INSERT "ZOMBIE" USER ----------------------------------------
INSERT INTO users
(username,is_admin,name,email,avatar_url)
VALUES
('zombie', false, 'Zombie', 'zombie@localhost', '/uploads/avatars/zombie.png')
;
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000010_create_projects_table.sql.down.sql
-- DROP TABLE "projects" ---------------------------------------
DROP TABLE IF EXISTS "projects";
-- -------------------------------------------------------------
@@ -1,20 +0,0 @@
-- internal/db/migrations/2026_01_01_000010_create_projects_table.sql.up.sql
-- CREATE TABLE "projects" -------------------------------------
CREATE TABLE IF NOT EXISTS "projects"(
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"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,
"status" Text,
"priority" Text,
"start_date" DateTime,
"target_date" DateTime,
"completed_at" DateTime,
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DateTime,
"deleted_at" DateTime
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000011_create_project_user_table.sql.down.sql
-- DROP TABLE "project_user" -----------------------------------
DROP TABLE IF EXISTS "project_user";
-- -------------------------------------------------------------
@@ -1,13 +0,0 @@
-- internal/db/migrations/2026_01_01_000011_create_project_user_table.sql.up.sql
-- CREATE TABLE "project_user" ---------------------------------
CREATE TABLE IF NOT EXISTS "project_user" (
"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,
CONSTRAINT "idx_project_user" UNIQUE ( project_id, user_id )
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000011_create_project_labels_table.sql.down.sql
-- DROP TABLE "project_labels" ---------------------------------
DROP TABLE IF EXISTS "project_labels";
-- -------------------------------------------------------------
@@ -1,14 +0,0 @@
-- internal/db/migrations/2026_01_01_000011_create_project_labels_table.sql.up.sql
-- CREATE TABLE "project_labels" -------------------------------
CREATE TABLE IF NOT EXISTS "project_labels" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"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,
"deleted_at" DateTime,
CONSTRAINT "idx_project_labels" UNIQUE ( project_id, label )
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000013_create_project_links_table.sql.down.sql
-- DROP TABLE "project_links" ----------------------------------
DROP TABLE IF EXISTS "project_links";
-- -------------------------------------------------------------
@@ -1,12 +0,0 @@
-- internal/db/migrations/2026_01_01_000013_create_project_links_table.sql.up.sql
-- CREATE TABLE "project_links" --------------------------------
CREATE TABLE IF NOT EXISTS "project_links" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"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
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000014_create_project_attachments_table.sql.down.sql
-- DROP TABLE "project_attachments" ----------------------------
DROP TABLE IF EXISTS "project_attachments";
-- -------------------------------------------------------------
@@ -1,15 +0,0 @@
-- internal/db/migrations/2026_01_01_000014_create_project_attachments_table.sql.up.sql
-- CREATE TABLE "project_attachments" --------------------------
CREATE TABLE IF NOT EXISTS "project_attachments" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"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,
"mimetype" TEXT NOT NULL,
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted_at" DateTime
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000015_create_project_favorites_table.sql.down.sql
-- DROP TABLE "project_favorites" ------------------------------
DROP TABLE IF EXISTS "project_favorites";
@@ -1,13 +0,0 @@
-- internal/db/migrations/2026_01_01_000015_create_project_favorites_table.sql.up.sql
-- CREATE TABLE "project_favorites" ----------------------------
CREATE TABLE IF NOT EXISTS "project_favorites" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"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 )
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_00_000007_create_project_dependencies_table.sql.down.sql
-- DROP TABLE "project_dependencies" -----------------------------
DROP TABLE IF EXISTS "project_dependencies";
@@ -1,11 +0,0 @@
-- internal/db/migrations/2026_01_00_000007_create_project_dependencies_table.sql.up.sql
-- CREATE TABLE "project_dependencies" -----------------------------
CREATE TABLE IF NOT EXISTS "project_dependencies" (
"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 )
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000020_create_issues_table.sql.down.sql
-- DROP TABLE "issues" -----------------------------------------
DROP TABLE IF EXISTS "issues";
-- -------------------------------------------------------------
@@ -1,35 +0,0 @@
-- internal/db/migrations/2026_01_01_000020_create_issues_table.sql.up.sql
-- CREATE TABLE "issues" ---------------------------------------
CREATE TABLE IF NOT EXISTS "issues" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"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,
"status" Text,
"priority" Text,
"start_date" DateTime,
"target_date" DateTime,
"completed_at" DateTime,
"parent_issue_id" Integer REFERENCES "issues"("id"),
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DateTime,
"deleted_at" DateTime,
CONSTRAINT "uni_project_issue_id" UNIQUE ( project_id, project_issue_id )
);
-- -------------------------------------------------------------
-- CREATE INDEX "index_creator_id" -----------------------------
CREATE INDEX IF NOT EXISTS "index_creator_id" ON "issues"( "creator_id" );
-- -------------------------------------------------------------
-- CREATE INDEX "index_project_id" -----------------------------
CREATE INDEX IF NOT EXISTS "index_project_id" ON "issues"( "project_id" );
-- -------------------------------------------------------------
-- CREATE INDEX "index_assignee_id" ----------------------------
CREATE INDEX IF NOT EXISTS "index_assignee_id" ON "issues"( "assignee_id" );
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000021_create_issue_labels_table.sql.down.sql
-- DROP TABLE "issue_labels" -----------------------------------
DROP TABLE IF EXISTS "issue_labels";
-- -------------------------------------------------------------
@@ -1,13 +0,0 @@
-- internal/db/migrations/2026_01_01_000021_create_issue_labels_table.sql.up.sql
-- CREATE TABLE "issue_labels" ---------------------------------
CREATE TABLE IF NOT EXISTS "issue_labels" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"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 )
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000022_create_issue_links_table.sql.down.sql
-- DROP TABLE "issue_links" ------------------------------------
DROP TABLE IF EXISTS "issue_links";
-- -------------------------------------------------------------
@@ -1,12 +0,0 @@
-- internal/db/migrations/2026_01_01_000022_create_issue_links_table.sql.up.sql
-- CREATE TABLE "issue_links" ----------------------------------
CREATE TABLE IF NOT EXISTS "issue_links" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"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
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000023_create_issue_attachments_table.sql.down.sql
-- DROP TABLE "issue_attachments" ------------------------------
DROP TABLE IF EXISTS "issue_attachments";
-- -------------------------------------------------------------
@@ -1,15 +0,0 @@
-- internal/db/migrations/2026_01_01_000023_create_issue_attachments_table.sql.up.sql
-- CREATE TABLE "issue_attachments" ----------------------------
CREATE TABLE IF NOT EXISTS "issue_attachments" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"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,
"mimetype" TEXT NOT NULL,
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted_at" DateTime
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000005_create_issue_blockers_table.sql.down.sql
-- DROP TABLE "issue_blockers" ---------------------------------
DROP TABLE IF EXISTS "issue_blockers";
-- -------------------------------------------------------------
@@ -1,10 +0,0 @@
-- internal/db/migrations/2026_01_01_000005_create_issue_blockers_table.sql.up.sql
-- CREATE TABLE "issue_blockers" -------------------------------
CREATE TABLE IF NOT EXISTS "issue_blockers" (
"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 )
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000024_create_issue_comments_table.sql.down.sql
-- DROP TABLE "issue_comments" ---------------------------------
DROP TABLE IF EXISTS "issue_comments";
-- -------------------------------------------------------------
@@ -1,14 +0,0 @@
-- internal/db/migrations/2026_01_01_000024_create_issue_comments_table.sql.up.sql
-- CREATE TABLE "issue_comments" -------------------------------
CREATE TABLE IF NOT EXISTS "issue_comments" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"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,
"resolved_at" DateTime,
"deleted_at" DateTime
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000106_create_issue_comment_links_table.sql.down.sql
-- DROP TABLE "issue_comment_links" ----------------------------
DROP TABLE IF EXISTS "issue_comment_links";
-- -------------------------------------------------------------
@@ -1,12 +0,0 @@
-- internal/db/migrations/2026_01_01_000106_create_issue_comment_links_table.sql.up.sql
-- 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 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
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_01_000107_create_issue_comment_attachments_table.sql.down.sql
-- DROP TABLE "issue_comment_attachments" --------------------------
DROP TABLE IF EXISTS "issue_comment_attachments";
-- -------------------------------------------------------------
@@ -1,15 +0,0 @@
-- internal/db/migrations/2026_01_01_000107_create_issue_comment_attachments_table.sql.up.sql
-- 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 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,
"mimetype" TEXT NOT NULL,
"created_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted_at" DateTime
);
-- -------------------------------------------------------------
@@ -1,5 +0,0 @@
-- internal/db/migrations/2026_01_02_000001_create_webhook_receipts_table.sql.down.sql
-- DROP TABLE "webhook_receipts" -------------------------------
DROP TABLE IF EXISTS "webhook_receipts";
-- -------------------------------------------------------------
@@ -1,15 +0,0 @@
-- internal/db/migrations/2026_01_02_000001_create_webhook_receipts_table.sql.up.sql
-- CREATE TABLE "webhook_receipts" -------------------------------
CREATE TABLE IF NOT EXISTS "webhook_receipts" (
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"raw_payload" Text NOT NULL,
"source" Text NOT NULL,
"event_type" Text NOT NULL,
"delivery_id" Text NOT NULL,
"received_at" DateTime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"processing_status" Text NOT NULL DEFAULT 'pending',
"failure_reason" Text,
CONSTRAINT "unique_delivery_id" UNIQUE ( delivery_id )
);
-- -------------------------------------------------------------
-40
View File
@@ -1,40 +0,0 @@
#!/usr/bin/bash
for up_file in *.up.sql; do
down_file="${up_file%.up.sql}.down.sql"
quoted_text=$(sed -n '3s/[^"]*\("[^"]*"\).*/\1/p' "$up_file")
first_line=$(head -n 1 "$up_file")
if [[ "$first_line" != *".up.sql" ]]; then
sed -i "1s/$/\.up\.sql/" "$up_file"
fi
head -n 3 "$up_file" > "$down_file"
echo "DROP TABLE IF EXISTS ${quoted_text};" >> "$down_file"
tail -n 1 "$up_file" >> "$down_file"
done
sed -i 's/\bCREATE\b/DROP/g' *.down.sql
for file in *.sql; do
[ -f "$file" ] || continue
line3=$(sed -n '3p' "$file")
len=${#line3}
if [ "$len" -lt 64 ]; then
needed=$((64 - len))
dashes=$(printf '%*s' "$needed" | tr ' ' '-')
sed -i "3s/$/$dashes/" "$file"
fi
done
for file in *.down.sql; do
[ -f "$file" ] || continue
first_line=$(head -n 1 "$file")
if [[ "$first_line" == *".up.sql" ]]; then
sed -i '1s/\.up\.sql$/\.down\.sql/' "$file"
fi
done
-24
View File
@@ -1,24 +0,0 @@
#!/usr/bin/env bash
DB_NAME="database.sqlite"
if [ -z "$1" ]; then
echo "You need to tell me up or down"
exit 1
fi
if [[ "$1" == "up" ]]; then
rm -f "$DB_NAME"
touch "$DB_NAME"
for file in migrations/*.up.sql; do
echo "Executing $file..."
sqlite3 "$DB_NAME" < "$file"
done
fi
if [[ "$1" == "down" ]]; then
for file in migrations/*.down.sql; do
echo "Executing $file..."
sqlite3 "$DB_NAME" < "$file"
done
fi
-2
View File
@@ -1,2 +0,0 @@
*
!.gitignore