Skip to content

Commit

Permalink
[OPIK-309] Add prompt library tables (#516)
Browse files Browse the repository at this point in the history
* [OPIK-309] Add prompt library tables

* Make migration safer

* Change unique key

* Update 000004_add_prompt_library_tables.sql

* Update 000004_add_prompt_library_tables.sql

* Update 000004_add_prompt_library_tables.sql
  • Loading branch information
thiagohora authored Oct 31, 2024
1 parent 7ce9bbc commit b622d95
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--liquibase formatted sql
--changeset thiagohora:add_prompt_library_tables

CREATE TABLE IF NOT EXISTS prompts (
id CHAR(36) NOT NULL,
name VARCHAR(255) NOT NULL,
description VARCHAR(255),
created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
created_by VARCHAR(100) NOT NULL DEFAULT 'admin',
last_updated_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
last_updated_by VARCHAR(100) NOT NULL DEFAULT 'admin',
workspace_id VARCHAR(150) NOT NULL,
CONSTRAINT `prompts_pk` PRIMARY KEY (id),
CONSTRAINT `prompts_workspace_id_name_uk` UNIQUE (workspace_id, name)
);

CREATE TABLE IF NOT EXISTS prompt_versions (
id CHAR(36) NOT NULL,
prompt_id CHAR(36) NOT NULL,
commit VARCHAR(7) NOT NULL,
template MEDIUMTEXT NOT NULL,
created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
created_by VARCHAR(100) NOT NULL DEFAULT 'admin',
last_updated_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
last_updated_by VARCHAR(100) NOT NULL DEFAULT 'admin',
workspace_id VARCHAR(150) NOT NULL,
CONSTRAINT `prompt_versions_pk` PRIMARY KEY (id),
CONSTRAINT `prompt_versions_prompt_id_version_uk` UNIQUE (workspace_id, prompt_id, commit)
);

--rollback DROP TABLE IF EXISTS prompt_versions;
--rollback DROP TABLE IF EXISTS prompts;

0 comments on commit b622d95

Please sign in to comment.