Skip to content

Commit d7af855

Browse files
committed
add migrations
1 parent 346037b commit d7af855

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

taco/internal/atlas_loader.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ func adaptSQL(sql, dialect string) string {
110110
sql = strings.ReplaceAll(sql, "integer", "int")
111111
// Fix DEFAULT clause - PostgreSQL uses single quotes for string literals
112112
sql = strings.ReplaceAll(sql, "DEFAULT \"allow\"", "DEFAULT 'allow'")
113+
sql = strings.ReplaceAll(sql, "DEFAULT \"active\"", "DEFAULT 'active'")
113114
sql = strings.ReplaceAll(sql, "DEFAULT \"\"", "DEFAULT ''")
114115
case "mysql":
115116
// MySQL uses backticks (already correct from SQLite)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- Create "tokens" table
2+
CREATE TABLE `tokens` (
3+
`id` varchar(36) NOT NULL,
4+
`user_id` varchar(255) NOT NULL,
5+
`org_id` varchar(255) NOT NULL,
6+
`token` varchar(255) NOT NULL,
7+
`name` varchar(255) NULL,
8+
`status` varchar(20) NULL DEFAULT "active",
9+
`created_at` datetime NULL,
10+
`updated_at` datetime NULL,
11+
`last_used_at` datetime NULL,
12+
`expires_at` datetime NULL,
13+
PRIMARY KEY (`id`),
14+
INDEX `idx_tokens_org_id` (`org_id`),
15+
UNIQUE INDEX `idx_tokens_token` (`token`),
16+
INDEX `idx_tokens_user_id` (`user_id`)
17+
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Create "tokens" table
2+
CREATE TABLE "public"."tokens" (
3+
"id" character varying(36) NOT NULL,
4+
"user_id" character varying(255) NOT NULL,
5+
"org_id" character varying(255) NOT NULL,
6+
"token" character varying(255) NOT NULL,
7+
"name" character varying(255) NULL,
8+
"status" character varying(20) NULL DEFAULT 'active',
9+
"created_at" timestamptz NULL,
10+
"updated_at" timestamptz NULL,
11+
"last_used_at" timestamptz NULL,
12+
"expires_at" timestamptz NULL,
13+
PRIMARY KEY ("id")
14+
);
15+
-- Create index "idx_tokens_org_id" to table: "tokens"
16+
CREATE INDEX "idx_tokens_org_id" ON "public"."tokens" ("org_id");
17+
-- Create index "idx_tokens_token" to table: "tokens"
18+
CREATE UNIQUE INDEX "idx_tokens_token" ON "public"."tokens" ("token");
19+
-- Create index "idx_tokens_user_id" to table: "tokens"
20+
CREATE INDEX "idx_tokens_user_id" ON "public"."tokens" ("user_id");
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Create "tokens" table
2+
CREATE TABLE `tokens` (
3+
`id` varchar NULL,
4+
`user_id` varchar NOT NULL,
5+
`org_id` varchar NOT NULL,
6+
`token` varchar NOT NULL,
7+
`name` varchar NULL,
8+
`status` varchar NULL DEFAULT 'active',
9+
`created_at` datetime NULL,
10+
`updated_at` datetime NULL,
11+
`last_used_at` datetime NULL,
12+
`expires_at` datetime NULL,
13+
PRIMARY KEY (`id`)
14+
);
15+
-- Create index "idx_tokens_token" to table: "tokens"
16+
CREATE UNIQUE INDEX `idx_tokens_token` ON `tokens` (`token`);
17+
-- Create index "idx_tokens_org_id" to table: "tokens"
18+
CREATE INDEX `idx_tokens_org_id` ON `tokens` (`org_id`);
19+
-- Create index "idx_tokens_user_id" to table: "tokens"
20+
CREATE INDEX `idx_tokens_user_id` ON `tokens` (`user_id`);

0 commit comments

Comments
 (0)