-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
description: This file contains the migration steps for the database schema. | ||
plan: | ||
- id: 01J6EWQ9NQRBQA3GT3FTCSRPJN | ||
description: Create objects table | ||
up: | ||
- | # sql | ||
INSERT INTO "jky_objects" ( | ||
"object_ulid", | ||
"object_data", | ||
"sha256_hash", | ||
"stake_key_hash", | ||
"object_type", | ||
"tokens_used", | ||
"indexing_txid", | ||
"indexing_tx_on_chain", | ||
"preparation_txid", | ||
"preparation_tx_submitted_at", | ||
"preparation_tx_on_chain" | ||
) VALUES ( | ||
'01F8MECHJJM6F2Q7VJ0HJK9TRA', -- object_ulid (example ULID) | ||
'hello world', -- object_data (example binary data) | ||
'C1E5AC4290D1FF3E95EF50DF90CFEF832BFF95F43F98CBBFA3EAFDC07C169120', -- sha256_hash (example SHA-256 hash) | ||
'A0B1C2D3E4F5G6H7I8J9K0L1M2N3O4P5Q6R7S8T9U0V1W2X3Y4Z5A6B7C8D9E00', -- stake_key_hash (example stake key hash) | ||
'example_object_type', -- object_type (example object type) | ||
100, -- tokens_used (example number of tokens) | ||
'3D1F5A93BFCC442D8F344D986D4FAE98D39B8A7A6BB90E20A4BFAB3EC3B66A1A', -- indexing_txid (example txid) | ||
TRUE, -- indexing_tx_on_chain (true/false) | ||
'9A4CF2B1D2F3G4H5I6J7K8L9M0N1O2P3Q4R5S6T7U8V9W0X1Y2Z3A4B5C6D7E8F', -- preparation_txid (example txid) | ||
'2024-09-13 10:15:00', -- preparation_tx_submitted_at (example timestamp) | ||
TRUE -- preparation_tx_on_chain (true/false) | ||
); | ||
down: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
description: This file contains the migration steps for the database schema. | ||
plan: | ||
- id: 01J6EWQ9NQRBQA3GT3FTCSRPJN | ||
description: Create objects table | ||
up: | ||
- | # sql | ||
-- Objects represent the data that is to be stored on-chain. Objects are | ||
-- composed of one or more shards. Each shard is a piece of the object's data | ||
-- that is stored on-chain. The shards are stored in the Shards table. | ||
CREATE TABLE "jky_objects" ( | ||
"object_ulid" CHAR(26) PRIMARY KEY, -- Unique identifier for objects | ||
"object_data" BYTEA NOT NULL, -- Binary data representing the object | ||
"sha256_hash" CHAR(64) NOT NULL UNIQUE, -- SHA-256 hash of the object data | ||
"stake_key_hash" CHAR(64) NOT NULL, -- Stake hash owner of the object | ||
"object_type" TEXT NOT NULL, -- Type of the object as a string | ||
"tokens_used" INT NOT NULL, -- Number of tokens used by the object | ||
"indexing_txid" CHAR(64), -- Transaction ID of the indexing tx | ||
"indexing_tx_on_chain" BOOLEAN NOT NULL, -- Indicates whether the object is on-chain | ||
"preparation_txid" CHAR(64), -- Transaction ID of the preparation tx | ||
"preparation_tx_submitted_at" TIMESTAMP, -- Timestamp of the preparation tx submission | ||
"preparation_tx_on_chain" BOOLEAN NOT NULL, -- Enough UTxOs to put object on-chain | ||
-- Constraint to enforce valid ULID | ||
CONSTRAINT "valid_ulid_constraint" | ||
CHECK ("object_ulid" ~ '^[0-9A-HJKMNP-TV-Z]{26}$'), | ||
CONSTRAINT "preparation_txid_and_submitted_at_constraint" | ||
CHECK ( | ||
("preparation_txid" IS NULL AND "preparation_tx_submitted_at" IS NULL) OR | ||
("preparation_txid" IS NOT NULL AND "preparation_tx_submitted_at" IS NOT NULL) | ||
) | ||
) | ||
- | # sql | ||
CREATE INDEX "idx_stake_key_hash" ON "jky_objects" ("stake_key_hash") | ||
- | # sql | ||
CREATE INDEX "idx_sha256_hash" ON "jky_objects" ("sha256_hash") | ||
- | # sql | ||
CREATE INDEX "idx_indexing_txid" ON "jky_objects" ("indexing_txid") | ||
- | # sql | ||
CREATE INDEX "idx_preparation_txid" ON "jky_objects" ("preparation_txid") | ||
down: | ||
- | # sql | ||
DROP INDEX "idx_preparation_txid" | ||
- | # sql | ||
DROP INDEX "idx_indexing_txid" | ||
- | # sql | ||
DROP INDEX "idx_sha256_hash" | ||
- | # sql | ||
DROP INDEX "idx_stake_key_hash" | ||
- | # sql | ||
DROP TABLE "jky_objects" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
description: This file contains the migration steps for the database schema. | ||
plan: | ||
- id: 01J6EWQ9NQRBQA3GT3FTCSRPJN | ||
description: Create objects table | ||
up: | ||
- | # sql | ||
SELECT | ||
"object_ulid", | ||
"object_data", | ||
"sha256_hash", | ||
"stake_key_hash", | ||
"object_type", | ||
"tokens_used", | ||
"indexing_txid", | ||
"indexing_tx_on_chain", | ||
"preparation_txid", | ||
"preparation_tx_submitted_at", | ||
"preparation_tx_on_chain" | ||
FROM "jky_objects"; | ||
down: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
description: This file contains the migration steps for the database schema. | ||
plan: | ||
- id: 01J6EWQ9NQRBQA3GT3FTCSRPJN | ||
description: Create objects table | ||
up: | ||
- | # sql | ||
SELECT table_name | ||
FROM information_schema.tables | ||
WHERE table_schema = 'public' | ||
AND table_type = 'BASE TABLE' | ||
down: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters