Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion SHARP/database/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,19 @@ CREATE TABLE IF NOT EXISTS used_hashcash_tokens (
token TEXT PRIMARY KEY,
expires_at TIMESTAMPTZ NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_used_hashcash_tokens_expires_at ON used_hashcash_tokens(expires_at);
CREATE INDEX IF NOT EXISTS idx_used_hashcash_tokens_expires_at ON used_hashcash_tokens(expires_at);

DROP TYPE IF EXISTS migration_status;

CREATE TYPE migration_status AS ENUM (
'scheduled', -- Initial state
'running', -- Migration in progress
'failed', -- Migration failed
'migrated' -- Successfully migrated
);

CREATE TABLE IF NOT EXISTS migrations (
id TEXT PRIMARY KEY,
status migration_status DEFAULT 'scheduled',
modfied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
14 changes: 14 additions & 0 deletions SHARP/database/migrations/00_migration_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
DROP TYPE IF EXISTS migration_status;

CREATE TYPE migration_status AS ENUM (
'scheduled', -- Initial state
'running', -- Migration in progress
'failed', -- Migration failed
'migrated' -- Successfully migrated
);

CREATE TABLE IF NOT EXISTS migrations (
id TEXT PRIMARY KEY,
status migration_status DEFAULT 'scheduled',
modfied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
5 changes: 5 additions & 0 deletions SHARP/database/migrations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Database Migrations

Add here the databayse migration, you want to run, also adjust the `../init.sql` file to include those chnages.

After that, also add them to the `MIGRATIONS` array, so that they are applied automatically.
Loading