diff --git a/drizzle/0002_sharp_anthem.sql b/drizzle/0002_sharp_anthem.sql new file mode 100644 index 00000000..a6a408d9 --- /dev/null +++ b/drizzle/0002_sharp_anthem.sql @@ -0,0 +1 @@ +CREATE INDEX "idx_machines_name" ON "machines" USING btree ("name"); \ No newline at end of file diff --git a/drizzle/meta/0002_snapshot.json b/drizzle/meta/0002_snapshot.json new file mode 100644 index 00000000..8e52f0f0 --- /dev/null +++ b/drizzle/meta/0002_snapshot.json @@ -0,0 +1,1047 @@ +{ + "id": "ebccf667-8a1c-45e0-a3d9-d3e990ce24fc", + "prevId": "fa772082-303a-4400-a6f3-66b94a7985f8", + "version": "7", + "dialect": "postgresql", + "tables": { + "auth.users": { + "name": "users", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invited_users": { + "name": "invited_users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "generated": { + "as": "first_name || ' ' || last_name", + "type": "stored" + } + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'guest'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "invite_sent_at": { + "name": "invite_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "invited_users_email_unique": { + "name": "invited_users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.issue_comments": { + "name": "issue_comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_system": { + "name": "is_system", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_issue_comments_issue_id": { + "name": "idx_issue_comments_issue_id", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_issue_comments_author_id": { + "name": "idx_issue_comments_author_id", + "columns": [ + { + "expression": "author_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "issue_comments_issue_id_issues_id_fk": { + "name": "issue_comments_issue_id_issues_id_fk", + "tableFrom": "issue_comments", + "tableTo": "issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "issue_comments_author_id_user_profiles_id_fk": { + "name": "issue_comments_author_id_user_profiles_id_fk", + "tableFrom": "issue_comments", + "tableTo": "user_profiles", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.issue_watchers": { + "name": "issue_watchers", + "schema": "", + "columns": { + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "idx_issue_watchers_user_id": { + "name": "idx_issue_watchers_user_id", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "issue_watchers_issue_id_issues_id_fk": { + "name": "issue_watchers_issue_id_issues_id_fk", + "tableFrom": "issue_watchers", + "tableTo": "issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "issue_watchers_user_id_user_profiles_id_fk": { + "name": "issue_watchers_user_id_user_profiles_id_fk", + "tableFrom": "issue_watchers", + "tableTo": "user_profiles", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "issue_watchers_issue_id_user_id_pk": { + "name": "issue_watchers_issue_id_user_id_pk", + "columns": [ + "issue_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.issues": { + "name": "issues", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "machine_initials": { + "name": "machine_initials", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issue_number": { + "name": "issue_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'new'" + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'minor'" + }, + "priority": { + "name": "priority", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'medium'" + }, + "consistency": { + "name": "consistency", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'intermittent'" + }, + "reported_by": { + "name": "reported_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "invited_reported_by": { + "name": "invited_reported_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "reporter_name": { + "name": "reporter_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reporter_email": { + "name": "reporter_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assigned_to": { + "name": "assigned_to", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_issues_assigned_to": { + "name": "idx_issues_assigned_to", + "columns": [ + { + "expression": "assigned_to", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_issues_reported_by": { + "name": "idx_issues_reported_by", + "columns": [ + { + "expression": "reported_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_issues_status": { + "name": "idx_issues_status", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_issues_created_at": { + "name": "idx_issues_created_at", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_issues_invited_reported_by": { + "name": "idx_issues_invited_reported_by", + "columns": [ + { + "expression": "invited_reported_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "issues_machine_initials_machines_initials_fk": { + "name": "issues_machine_initials_machines_initials_fk", + "tableFrom": "issues", + "tableTo": "machines", + "columnsFrom": [ + "machine_initials" + ], + "columnsTo": [ + "initials" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "issues_reported_by_user_profiles_id_fk": { + "name": "issues_reported_by_user_profiles_id_fk", + "tableFrom": "issues", + "tableTo": "user_profiles", + "columnsFrom": [ + "reported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "issues_invited_reported_by_invited_users_id_fk": { + "name": "issues_invited_reported_by_invited_users_id_fk", + "tableFrom": "issues", + "tableTo": "invited_users", + "columnsFrom": [ + "invited_reported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "issues_assigned_to_user_profiles_id_fk": { + "name": "issues_assigned_to_user_profiles_id_fk", + "tableFrom": "issues", + "tableTo": "user_profiles", + "columnsFrom": [ + "assigned_to" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_issue_number": { + "name": "unique_issue_number", + "nullsNotDistinct": false, + "columns": [ + "machine_initials", + "issue_number" + ] + } + }, + "policies": {}, + "checkConstraints": { + "reporter_check": { + "name": "reporter_check", + "value": "(\"issues\".\"reported_by\" IS NULL AND \"issues\".\"invited_reported_by\" IS NULL) OR\n (\"issues\".\"reported_by\" IS NOT NULL AND \"issues\".\"invited_reported_by\" IS NULL AND \"issues\".\"reporter_name\" IS NULL AND \"issues\".\"reporter_email\" IS NULL) OR\n (\"issues\".\"reported_by\" IS NULL AND \"issues\".\"invited_reported_by\" IS NOT NULL AND \"issues\".\"reporter_name\" IS NULL AND \"issues\".\"reporter_email\" IS NULL) OR\n (\"issues\".\"reported_by\" IS NULL AND \"issues\".\"invited_reported_by\" IS NULL AND (\"issues\".\"reporter_name\" IS NOT NULL OR \"issues\".\"reporter_email\" IS NOT NULL))" + } + }, + "isRLSEnabled": false + }, + "public.machines": { + "name": "machines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "initials": { + "name": "initials", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "next_issue_number": { + "name": "next_issue_number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "invited_owner_id": { + "name": "invited_owner_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_machines_owner_id": { + "name": "idx_machines_owner_id", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_machines_invited_owner_id": { + "name": "idx_machines_invited_owner_id", + "columns": [ + { + "expression": "invited_owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_machines_name": { + "name": "idx_machines_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "machines_owner_id_user_profiles_id_fk": { + "name": "machines_owner_id_user_profiles_id_fk", + "tableFrom": "machines", + "tableTo": "user_profiles", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "machines_invited_owner_id_invited_users_id_fk": { + "name": "machines_invited_owner_id_invited_users_id_fk", + "tableFrom": "machines", + "tableTo": "invited_users", + "columnsFrom": [ + "invited_owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "machines_initials_unique": { + "name": "machines_initials_unique", + "nullsNotDistinct": false, + "columns": [ + "initials" + ] + } + }, + "policies": {}, + "checkConstraints": { + "initials_check": { + "name": "initials_check", + "value": "initials ~ '^[A-Z0-9]{2,6}$'" + }, + "owner_check": { + "name": "owner_check", + "value": "(owner_id IS NULL OR invited_owner_id IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.notification_preferences": { + "name": "notification_preferences", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "email_enabled": { + "name": "email_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "in_app_enabled": { + "name": "in_app_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "email_notify_on_assigned": { + "name": "email_notify_on_assigned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "in_app_notify_on_assigned": { + "name": "in_app_notify_on_assigned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "email_notify_on_status_change": { + "name": "email_notify_on_status_change", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "in_app_notify_on_status_change": { + "name": "in_app_notify_on_status_change", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "email_notify_on_new_comment": { + "name": "email_notify_on_new_comment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "in_app_notify_on_new_comment": { + "name": "in_app_notify_on_new_comment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "email_notify_on_new_issue": { + "name": "email_notify_on_new_issue", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "in_app_notify_on_new_issue": { + "name": "in_app_notify_on_new_issue", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "email_watch_new_issues_global": { + "name": "email_watch_new_issues_global", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "in_app_watch_new_issues_global": { + "name": "in_app_watch_new_issues_global", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "idx_notif_prefs_global_watch_email": { + "name": "idx_notif_prefs_global_watch_email", + "columns": [ + { + "expression": "email_watch_new_issues_global", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_preferences_user_id_user_profiles_id_fk": { + "name": "notification_preferences_user_id_user_profiles_id_fk", + "tableFrom": "notification_preferences", + "tableTo": "user_profiles", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resource_id": { + "name": "resource_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "resource_type": { + "name": "resource_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_notifications_user_unread": { + "name": "idx_notifications_user_unread", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_user_id_user_profiles_id_fk": { + "name": "notifications_user_id_user_profiles_id_fk", + "tableFrom": "notifications", + "tableTo": "user_profiles", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_profiles": { + "name": "user_profiles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "generated": { + "as": "first_name || ' ' || last_name", + "type": "stored" + } + }, + "avatar_url": { + "name": "avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_profiles_email_unique": { + "name": "user_profiles_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 173a4e88..52d457a7 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -15,6 +15,13 @@ "when": 1768170240258, "tag": "0001_invited-users-rename", "breakpoints": true + }, + { + "idx": 2, + "version": "7", + "when": 1768502458607, + "tag": "0002_sharp_anthem", + "breakpoints": true } ] -} +} \ No newline at end of file diff --git a/src/server/db/schema.ts b/src/server/db/schema.ts index 1e66b6a2..b573d1d7 100644 --- a/src/server/db/schema.ts +++ b/src/server/db/schema.ts @@ -114,6 +114,7 @@ export const machines = pgTable( invitedOwnerIdIdx: index("idx_machines_invited_owner_id").on( t.invitedOwnerId ), + nameIdx: index("idx_machines_name").on(t.name), }) );