-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pg schema + orm setup with drizzle
- Loading branch information
1 parent
617f45d
commit eb35b22
Showing
11 changed files
with
1,223 additions
and
4 deletions.
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,13 @@ | ||
import * as dotenv from "dotenv"; | ||
import type { Config } from "drizzle-kit"; | ||
|
||
dotenv.config({ path: ".env.local" }); | ||
|
||
export default { | ||
schema: "./src/lib/drizzle/schema", | ||
out: "./src/lib/drizzle/client", | ||
driver: "pg", | ||
dbCredentials: { | ||
connectionString: `${process.env.POSTGRES_URL}?sslmode=require`, | ||
}, | ||
} satisfies Config; |
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
40 changes: 40 additions & 0 deletions
40
apps/maestro/src/lib/drizzle/client/0000_narrow_inertia.sql
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,40 @@ | ||
DO $$ BEGIN | ||
CREATE TYPE "kind" AS ENUM('canonical', 'standardized'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
CREATE TYPE "status" AS ENUM('deployed', 'pending'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "interchain_tokens" ( | ||
"token_id" varchar(64) PRIMARY KEY NOT NULL, | ||
"token_address" varchar(40), | ||
"token_name" text, | ||
"token_symbol" text, | ||
"token_decimals" integer, | ||
"chain_id" integer, | ||
"axelar_chain_id" varchar(48), | ||
"deployment_tx_hash" varchar(64), | ||
"deployer_address" varchar(40) NOT NULL, | ||
"kind" "kind" NOT NULL, | ||
"salt" varchar(64), | ||
"created_at" timestamp NOT NULL, | ||
"updated_at" timestamp NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "remote_interchain_tokens" ( | ||
"token_id" varchar(64) PRIMARY KEY NOT NULL, | ||
"origin_token_id" varchar(64), | ||
"chain_id" integer, | ||
"axelar_chain_id" varchar, | ||
"address" varchar(40), | ||
"status" "status", | ||
"deployment_tx_hash" varchar(64), | ||
"deployment_log_index" integer, | ||
"created_at" timestamp NOT NULL, | ||
"updated_at" timestamp NOT NULL | ||
); |
21 changes: 21 additions & 0 deletions
21
apps/maestro/src/lib/drizzle/client/0001_ordinary_blob.sql
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 @@ | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "token_id" SET DATA TYPE varchar(66);--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "token_address" SET DATA TYPE varchar(42);--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "token_address" SET NOT NULL;--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "token_name" SET DATA TYPE varchar(100);--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "token_name" SET NOT NULL;--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "token_symbol" SET DATA TYPE varchar(100);--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "token_symbol" SET NOT NULL;--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "token_decimals" SET DATA TYPE smallint;--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "token_decimals" SET NOT NULL;--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "chain_id" SET NOT NULL;--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "axelar_chain_id" SET DATA TYPE varchar(66);--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "axelar_chain_id" SET NOT NULL;--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "deployment_tx_hash" SET DATA TYPE varchar(66);--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "deployer_address" SET DATA TYPE varchar(42);--> statement-breakpoint | ||
ALTER TABLE "interchain_tokens" ALTER COLUMN "salt" SET DATA TYPE varchar(66);--> statement-breakpoint | ||
ALTER TABLE "remote_interchain_tokens" ALTER COLUMN "token_id" SET DATA TYPE varchar(66);--> statement-breakpoint | ||
ALTER TABLE "remote_interchain_tokens" ALTER COLUMN "origin_token_id" SET DATA TYPE varchar(66);--> statement-breakpoint | ||
ALTER TABLE "remote_interchain_tokens" ALTER COLUMN "address" SET DATA TYPE varchar(42);--> statement-breakpoint | ||
ALTER TABLE "remote_interchain_tokens" ALTER COLUMN "deployment_tx_hash" SET DATA TYPE varchar(66);--> statement-breakpoint | ||
ALTER TABLE "remote_interchain_tokens" ADD COLUMN "deployment_status" "status";--> statement-breakpoint | ||
ALTER TABLE "remote_interchain_tokens" DROP COLUMN IF EXISTS "status"; |
188 changes: 188 additions & 0 deletions
188
apps/maestro/src/lib/drizzle/client/meta/0000_snapshot.json
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,188 @@ | ||
{ | ||
"version": "5", | ||
"dialect": "pg", | ||
"id": "585ea645-1fde-4995-bd80-8add01cec875", | ||
"prevId": "00000000-0000-0000-0000-000000000000", | ||
"tables": { | ||
"interchain_tokens": { | ||
"name": "interchain_tokens", | ||
"schema": "", | ||
"columns": { | ||
"token_id": { | ||
"name": "token_id", | ||
"type": "varchar(64)", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"token_address": { | ||
"name": "token_address", | ||
"type": "varchar(40)", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"token_name": { | ||
"name": "token_name", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"token_symbol": { | ||
"name": "token_symbol", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"token_decimals": { | ||
"name": "token_decimals", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"chain_id": { | ||
"name": "chain_id", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"axelar_chain_id": { | ||
"name": "axelar_chain_id", | ||
"type": "varchar(48)", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"deployment_tx_hash": { | ||
"name": "deployment_tx_hash", | ||
"type": "varchar(64)", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"deployer_address": { | ||
"name": "deployer_address", | ||
"type": "varchar(40)", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"kind": { | ||
"name": "kind", | ||
"type": "kind", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"salt": { | ||
"name": "salt", | ||
"type": "varchar(64)", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"created_at": { | ||
"name": "created_at", | ||
"type": "timestamp", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"updated_at": { | ||
"name": "updated_at", | ||
"type": "timestamp", | ||
"primaryKey": false, | ||
"notNull": true | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
}, | ||
"remote_interchain_tokens": { | ||
"name": "remote_interchain_tokens", | ||
"schema": "", | ||
"columns": { | ||
"token_id": { | ||
"name": "token_id", | ||
"type": "varchar(64)", | ||
"primaryKey": true, | ||
"notNull": true | ||
}, | ||
"origin_token_id": { | ||
"name": "origin_token_id", | ||
"type": "varchar(64)", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"chain_id": { | ||
"name": "chain_id", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"axelar_chain_id": { | ||
"name": "axelar_chain_id", | ||
"type": "varchar", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"address": { | ||
"name": "address", | ||
"type": "varchar(40)", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"status": { | ||
"name": "status", | ||
"type": "status", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"deployment_tx_hash": { | ||
"name": "deployment_tx_hash", | ||
"type": "varchar(64)", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"deployment_log_index": { | ||
"name": "deployment_log_index", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": false | ||
}, | ||
"created_at": { | ||
"name": "created_at", | ||
"type": "timestamp", | ||
"primaryKey": false, | ||
"notNull": true | ||
}, | ||
"updated_at": { | ||
"name": "updated_at", | ||
"type": "timestamp", | ||
"primaryKey": false, | ||
"notNull": true | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
} | ||
}, | ||
"enums": { | ||
"kind": { | ||
"name": "kind", | ||
"values": { | ||
"canonical": "canonical", | ||
"standardized": "standardized" | ||
} | ||
}, | ||
"status": { | ||
"name": "status", | ||
"values": { | ||
"deployed": "deployed", | ||
"pending": "pending" | ||
} | ||
} | ||
}, | ||
"schemas": {}, | ||
"_meta": { | ||
"schemas": {}, | ||
"tables": {}, | ||
"columns": {} | ||
} | ||
} |
Oops, something went wrong.