Skip to content

Commit

Permalink
feat(api): split index change into two migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahsnider committed Jun 4, 2024
1 parent 4aa76e1 commit 918a1fa
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 71 deletions.
4 changes: 4 additions & 0 deletions drizzle/0001_minor_dormammu.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DROP INDEX IF EXISTS "urls_blocked_index";--> statement-breakpoint
DROP INDEX IF EXISTS "urls_url_index";--> statement-breakpoint
DROP INDEX IF EXISTS "visits_url_short_base64_index";--> statement-breakpoint
DROP INDEX IF EXISTS "visits_timestamp_index";
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
DROP INDEX IF EXISTS "urls_blocked_index";--> statement-breakpoint
DROP INDEX IF EXISTS "urls_url_index";--> statement-breakpoint
DROP INDEX IF EXISTS "visits_url_short_base64_index";--> statement-breakpoint
DROP INDEX IF EXISTS "visits_timestamp_index";--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "urls_blocked_index" ON "urls" USING hash (blocked);--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "urls_url_index" ON "urls" USING hash (url);--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "visits_url_short_base64_index" ON "visits" USING hash (url_short_base64);--> statement-breakpoint
Expand Down
68 changes: 3 additions & 65 deletions drizzle/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "5285b7db-7d21-4825-98dc-077f7612ee83",
"id": "5e370c82-32f6-4b3a-9027-8cd493a75f34",
"prevId": "a1a9d125-cfb1-4769-baca-2f88b80c8dc9",
"version": "7",
"dialect": "postgresql",
Expand Down Expand Up @@ -58,38 +58,7 @@
"notNull": true
}
},
"indexes": {
"urls_blocked_index": {
"name": "urls_blocked_index",
"columns": [
{
"expression": "blocked",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "hash",
"with": {}
},
"urls_url_index": {
"name": "urls_url_index",
"columns": [
{
"expression": "url",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "hash",
"with": {}
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
Expand Down Expand Up @@ -118,38 +87,7 @@
"notNull": true
}
},
"indexes": {
"visits_url_short_base64_index": {
"name": "visits_url_short_base64_index",
"columns": [
{
"expression": "url_short_base64",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "hash",
"with": {}
},
"visits_timestamp_index": {
"name": "visits_timestamp_index",
"columns": [
{
"expression": "timestamp",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"indexes": {},
"foreignKeys": {
"visits_url_short_base64_urls_short_base64_fk": {
"name": "visits_url_short_base64_urls_short_base64_fk",
Expand Down
175 changes: 175 additions & 0 deletions drizzle/meta/0002_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
{
"id": "3f0e9c2d-6d60-4cc3-9426-dab6c1d7ac26",
"prevId": "5e370c82-32f6-4b3a-9027-8cd493a75f34",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.blocked_hostnames": {
"name": "blocked_hostnames",
"schema": "",
"columns": {
"hostname": {
"name": "hostname",
"type": "text",
"primaryKey": true,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.urls": {
"name": "urls",
"schema": "",
"columns": {
"blocked": {
"name": "blocked",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"short_base64": {
"name": "short_base64",
"type": "text",
"primaryKey": true,
"notNull": true
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": true
}
},
"indexes": {
"urls_blocked_index": {
"name": "urls_blocked_index",
"columns": [
{
"expression": "blocked",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "hash",
"with": {}
},
"urls_url_index": {
"name": "urls_url_index",
"columns": [
{
"expression": "url",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "hash",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.visits": {
"name": "visits",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"timestamp": {
"name": "timestamp",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"url_short_base64": {
"name": "url_short_base64",
"type": "text",
"primaryKey": false,
"notNull": true
}
},
"indexes": {
"visits_url_short_base64_index": {
"name": "visits_url_short_base64_index",
"columns": [
{
"expression": "url_short_base64",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "hash",
"with": {}
},
"visits_timestamp_index": {
"name": "visits_timestamp_index",
"columns": [
{
"expression": "timestamp",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"visits_url_short_base64_urls_short_base64_fk": {
"name": "visits_url_short_base64_urls_short_base64_fk",
"tableFrom": "visits",
"tableTo": "urls",
"columnsFrom": ["url_short_base64"],
"columnsTo": ["short_base64"],
"onDelete": "cascade",
"onUpdate": "cascade"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"schemas": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
11 changes: 9 additions & 2 deletions drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
{
"idx": 1,
"version": "7",
"when": 1717462907814,
"tag": "0001_flawless_maria_hill",
"when": 1717471829465,
"tag": "0001_minor_dormammu",
"breakpoints": true
},
{
"idx": 2,
"version": "7",
"when": 1717472064280,
"tag": "0002_sparkling_warstar",
"breakpoints": true
}
]
Expand Down

0 comments on commit 918a1fa

Please sign in to comment.