diff --git a/drizzle/0013_oval_dreaming_celestial.sql b/drizzle/0013_youthful_captain_britain.sql similarity index 61% rename from drizzle/0013_oval_dreaming_celestial.sql rename to drizzle/0013_youthful_captain_britain.sql index 703e2d7..698ceab 100644 --- a/drizzle/0013_oval_dreaming_celestial.sql +++ b/drizzle/0013_youthful_captain_britain.sql @@ -1,6 +1,7 @@ CREATE TABLE "web_faq_categories" ( "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "web_faq_categories_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "title" text NOT NULL, + "title_it" text NOT NULL, + "title_en" text NOT NULL, "icon" text, "created_by_id" bigint NOT NULL, "modified_by_id" bigint, @@ -10,8 +11,10 @@ CREATE TABLE "web_faq_categories" ( --> statement-breakpoint CREATE TABLE "web_faqs" ( "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "web_faqs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "title" text NOT NULL, - "description" text NOT NULL, + "title_it" text NOT NULL, + "title_en" text NOT NULL, + "description_it" text NOT NULL, + "description_en" text NOT NULL, "category_id" integer NOT NULL, "created_by_id" bigint NOT NULL, "modified_by_id" bigint, @@ -19,8 +22,25 @@ CREATE TABLE "web_faqs" ( "created_at" timestamp (0) with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint +CREATE TABLE "web_projects" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "web_projects_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "title" text NOT NULL, + "description_it" text NOT NULL, + "description_en" text NOT NULL, + "logo" text, + "link" text, + "category" text DEFAULT 'general' NOT NULL, + "order" integer DEFAULT 0 NOT NULL, + "created_by_id" bigint NOT NULL, + "modified_by_id" bigint, + "updated_at" timestamp (0) with time zone, + "created_at" timestamp (0) with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint ALTER TABLE "web_faq_categories" ADD CONSTRAINT "web_faq_categories_created_by_id_tg_permissions_user_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."tg_permissions"("user_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "web_faq_categories" ADD CONSTRAINT "web_faq_categories_modified_by_id_tg_permissions_user_id_fk" FOREIGN KEY ("modified_by_id") REFERENCES "public"."tg_permissions"("user_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "web_faqs" ADD CONSTRAINT "web_faqs_category_id_web_faq_categories_id_fk" FOREIGN KEY ("category_id") REFERENCES "public"."web_faq_categories"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "web_faqs" ADD CONSTRAINT "web_faqs_created_by_id_tg_permissions_user_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."tg_permissions"("user_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "web_faqs" ADD CONSTRAINT "web_faqs_modified_by_id_tg_permissions_user_id_fk" FOREIGN KEY ("modified_by_id") REFERENCES "public"."tg_permissions"("user_id") ON DELETE no action ON UPDATE no action; \ No newline at end of file +ALTER TABLE "web_faqs" ADD CONSTRAINT "web_faqs_modified_by_id_tg_permissions_user_id_fk" FOREIGN KEY ("modified_by_id") REFERENCES "public"."tg_permissions"("user_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "web_projects" ADD CONSTRAINT "web_projects_created_by_id_tg_permissions_user_id_fk" FOREIGN KEY ("created_by_id") REFERENCES "public"."tg_permissions"("user_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "web_projects" ADD CONSTRAINT "web_projects_modified_by_id_tg_permissions_user_id_fk" FOREIGN KEY ("modified_by_id") REFERENCES "public"."tg_permissions"("user_id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/drizzle/0014_remarkable_synch.sql b/drizzle/0014_remarkable_synch.sql deleted file mode 100644 index 4aae971..0000000 --- a/drizzle/0014_remarkable_synch.sql +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE "web_faq_categories" RENAME COLUMN "title" TO "title_it";--> statement-breakpoint -ALTER TABLE "web_faqs" RENAME COLUMN "title" TO "title_it";--> statement-breakpoint -ALTER TABLE "web_faqs" RENAME COLUMN "description" TO "description_it";--> statement-breakpoint -ALTER TABLE "web_faq_categories" ADD COLUMN "title_en" text NOT NULL;--> statement-breakpoint -ALTER TABLE "web_faqs" ADD COLUMN "title_en" text NOT NULL;--> statement-breakpoint -ALTER TABLE "web_faqs" ADD COLUMN "description_en" text NOT NULL; \ No newline at end of file diff --git a/drizzle/meta/0013_snapshot.json b/drizzle/meta/0013_snapshot.json index 1adcde9..0e67ba3 100644 --- a/drizzle/meta/0013_snapshot.json +++ b/drizzle/meta/0013_snapshot.json @@ -1,5 +1,5 @@ { - "id": "7cbf375c-6bd0-4e9b-a290-40c41134d70d", + "id": "11d256f8-c5b6-4390-9cd6-c75f64c558d2", "prevId": "ed5cf808-3f4a-45df-b384-69cac0367dc8", "version": "7", "dialect": "postgresql", @@ -1144,8 +1144,14 @@ "cycle": false } }, - "title": { - "name": "title", + "title_it": { + "name": "title_it", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title_en": { + "name": "title_en", "type": "text", "primaryKey": false, "notNull": true @@ -1238,14 +1244,26 @@ "cycle": false } }, - "title": { - "name": "title", + "title_it": { + "name": "title_it", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title_en": { + "name": "title_en", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description_it": { + "name": "description_it", "type": "text", "primaryKey": false, "notNull": true }, - "description": { - "name": "description", + "description_en": { + "name": "description_en", "type": "text", "primaryKey": false, "notNull": true @@ -1330,6 +1348,132 @@ "checkConstraints": {}, "isRLSEnabled": false }, + "public.web_projects": { + "name": "web_projects", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "web_projects_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description_it": { + "name": "description_it", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description_en": { + "name": "description_en", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "logo": { + "name": "logo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link": { + "name": "link", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'general'" + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_by_id": { + "name": "created_by_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "modified_by_id": { + "name": "modified_by_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (0) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (0) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "web_projects_created_by_id_tg_permissions_user_id_fk": { + "name": "web_projects_created_by_id_tg_permissions_user_id_fk", + "tableFrom": "web_projects", + "tableTo": "tg_permissions", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "user_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "web_projects_modified_by_id_tg_permissions_user_id_fk": { + "name": "web_projects_modified_by_id_tg_permissions_user_id_fk", + "tableFrom": "web_projects", + "tableTo": "tg_permissions", + "columnsFrom": [ + "modified_by_id" + ], + "columnsTo": [ + "user_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, "public.web_test": { "name": "web_test", "schema": "", diff --git a/drizzle/meta/0014_snapshot.json b/drizzle/meta/0014_snapshot.json deleted file mode 100644 index 36923d7..0000000 --- a/drizzle/meta/0014_snapshot.json +++ /dev/null @@ -1,1399 +0,0 @@ -{ - "id": "1f57937f-f9b1-4009-9d01-54eaeee323d7", - "prevId": "7cbf375c-6bd0-4e9b-a290-40c41134d70d", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.auth_accounts": { - "name": "auth_accounts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "account_id": { - "name": "account_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_id": { - "name": "provider_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "access_token": { - "name": "access_token", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "refresh_token": { - "name": "refresh_token", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "id_token": { - "name": "id_token", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "access_token_expires_at": { - "name": "access_token_expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "refresh_token_expires_at": { - "name": "refresh_token_expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "scope": { - "name": "scope", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "account_userId_idx": { - "name": "account_userId_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "auth_accounts_user_id_auth_users_id_fk": { - "name": "auth_accounts_user_id_auth_users_id_fk", - "tableFrom": "auth_accounts", - "tableTo": "auth_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.auth_passkey": { - "name": "auth_passkey", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "public_key": { - "name": "public_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "credential_id": { - "name": "credential_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "counter": { - "name": "counter", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "device_type": { - "name": "device_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "backed_up": { - "name": "backed_up", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "transports": { - "name": "transports", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "aaguid": { - "name": "aaguid", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "passkey_userId_idx": { - "name": "passkey_userId_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "passkey_credentialID_idx": { - "name": "passkey_credentialID_idx", - "columns": [ - { - "expression": "credential_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "auth_passkey_user_id_auth_users_id_fk": { - "name": "auth_passkey_user_id_auth_users_id_fk", - "tableFrom": "auth_passkey", - "tableTo": "auth_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.auth_sessions": { - "name": "auth_sessions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "token": { - "name": "token", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "session_userId_idx": { - "name": "session_userId_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "auth_sessions_user_id_auth_users_id_fk": { - "name": "auth_sessions_user_id_auth_users_id_fk", - "tableFrom": "auth_sessions", - "tableTo": "auth_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "auth_sessions_token_unique": { - "name": "auth_sessions_token_unique", - "nullsNotDistinct": false, - "columns": [ - "token" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.auth_users": { - "name": "auth_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email_verified": { - "name": "email_verified", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tg_id": { - "name": "tg_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "tg_username": { - "name": "tg_username", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "auth_users_email_unique": { - "name": "auth_users_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.auth_verifications": { - "name": "auth_verifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "identifier": { - "name": "identifier", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "verification_identifier_idx": { - "name": "verification_identifier_idx", - "columns": [ - { - "expression": "identifier", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tg_audit_log": { - "name": "tg_audit_log", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "tg_audit_log_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "admin_id": { - "name": "admin_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "target_id": { - "name": "target_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "group_id": { - "name": "group_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "type": { - "name": "type", - "type": "varchar(32)", - "primaryKey": false, - "notNull": true - }, - "until": { - "name": "until", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": false - }, - "reason": { - "name": "reason", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "auditlog_adminid_idx": { - "name": "auditlog_adminid_idx", - "columns": [ - { - "expression": "admin_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tg_grants": { - "name": "tg_grants", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "tg_grants_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "user_id": { - "name": "user_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "granted_by_id": { - "name": "granted_by_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "valid_since": { - "name": "valid_since", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true - }, - "valid_until": { - "name": "valid_until", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true - }, - "interrupted_by_id": { - "name": "interrupted_by_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "reason": { - "name": "reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "tg_grants_user_id_idx": { - "name": "tg_grants_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "tg_grants_granted_by_id_tg_permissions_user_id_fk": { - "name": "tg_grants_granted_by_id_tg_permissions_user_id_fk", - "tableFrom": "tg_grants", - "tableTo": "tg_permissions", - "columnsFrom": [ - "granted_by_id" - ], - "columnsTo": [ - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "tg_grants_interrupted_by_id_tg_permissions_user_id_fk": { - "name": "tg_grants_interrupted_by_id_tg_permissions_user_id_fk", - "tableFrom": "tg_grants", - "tableTo": "tg_permissions", - "columnsFrom": [ - "interrupted_by_id" - ], - "columnsTo": [ - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tg_groups": { - "name": "tg_groups", - "schema": "", - "columns": { - "telegram_id": { - "name": "telegram_id", - "type": "bigint", - "primaryKey": true, - "notNull": true - }, - "title": { - "name": "title", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "tag": { - "name": "tag", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "link": { - "name": "link", - "type": "varchar(128)", - "primaryKey": false, - "notNull": false - }, - "hide": { - "name": "hide", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "tg_groups_link_unique": { - "name": "tg_groups_link_unique", - "nullsNotDistinct": false, - "columns": [ - "link" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tg_link": { - "name": "tg_link", - "schema": "", - "columns": { - "code": { - "name": "code", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "ttl": { - "name": "ttl", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tg_username": { - "name": "tg_username", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tg_id": { - "name": "tg_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "tg_link_user_id_auth_users_id_fk": { - "name": "tg_link_user_id_auth_users_id_fk", - "tableFrom": "tg_link", - "tableTo": "auth_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "tg_link_tg_id_unique": { - "name": "tg_link_tg_id_unique", - "nullsNotDistinct": false, - "columns": [ - "tg_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tg_messages": { - "name": "tg_messages", - "schema": "", - "columns": { - "chat_id": { - "name": "chat_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "author_id": { - "name": "author_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "timestamp": { - "name": "timestamp", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "varchar(8704)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "tg_messages_chat_id_message_id_pk": { - "name": "tg_messages_chat_id_message_id_pk", - "columns": [ - "chat_id", - "message_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tg_group_admins": { - "name": "tg_group_admins", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "group_id": { - "name": "group_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "added_by_id": { - "name": "added_by_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "user_id_idx": { - "name": "user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "tg_group_admins_user_id_group_id_pk": { - "name": "tg_group_admins_user_id_group_id_pk", - "columns": [ - "user_id", - "group_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tg_permissions": { - "name": "tg_permissions", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "bigint", - "primaryKey": true, - "notNull": true - }, - "roles": { - "name": "roles", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{\"admin\"}'" - }, - "added_by_id": { - "name": "added_by_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "modified_by_id": { - "name": "modified_by_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tg_test": { - "name": "tg_test", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "tg_test_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "text": { - "name": "text", - "type": "varchar", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tg_users": { - "name": "tg_users", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "bigint", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "varchar(192)", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "varchar(192)", - "primaryKey": false, - "notNull": false - }, - "username": { - "name": "username", - "type": "varchar(128)", - "primaryKey": false, - "notNull": false - }, - "is_bot": { - "name": "is_bot", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "lang_code": { - "name": "lang_code", - "type": "varchar(35)", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.web_faq_categories": { - "name": "web_faq_categories", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "web_faq_categories_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "title_it": { - "name": "title_it", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title_en": { - "name": "title_en", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "icon": { - "name": "icon", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by_id": { - "name": "created_by_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "modified_by_id": { - "name": "modified_by_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "web_faq_categories_created_by_id_tg_permissions_user_id_fk": { - "name": "web_faq_categories_created_by_id_tg_permissions_user_id_fk", - "tableFrom": "web_faq_categories", - "tableTo": "tg_permissions", - "columnsFrom": [ - "created_by_id" - ], - "columnsTo": [ - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "web_faq_categories_modified_by_id_tg_permissions_user_id_fk": { - "name": "web_faq_categories_modified_by_id_tg_permissions_user_id_fk", - "tableFrom": "web_faq_categories", - "tableTo": "tg_permissions", - "columnsFrom": [ - "modified_by_id" - ], - "columnsTo": [ - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.web_faqs": { - "name": "web_faqs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "web_faqs_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "title_it": { - "name": "title_it", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title_en": { - "name": "title_en", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description_it": { - "name": "description_it", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description_en": { - "name": "description_en", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category_id": { - "name": "category_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "created_by_id": { - "name": "created_by_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "modified_by_id": { - "name": "modified_by_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (0) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "web_faqs_category_id_web_faq_categories_id_fk": { - "name": "web_faqs_category_id_web_faq_categories_id_fk", - "tableFrom": "web_faqs", - "tableTo": "web_faq_categories", - "columnsFrom": [ - "category_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "web_faqs_created_by_id_tg_permissions_user_id_fk": { - "name": "web_faqs_created_by_id_tg_permissions_user_id_fk", - "tableFrom": "web_faqs", - "tableTo": "tg_permissions", - "columnsFrom": [ - "created_by_id" - ], - "columnsTo": [ - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "web_faqs_modified_by_id_tg_permissions_user_id_fk": { - "name": "web_faqs_modified_by_id_tg_permissions_user_id_fk", - "tableFrom": "web_faqs", - "tableTo": "tg_permissions", - "columnsFrom": [ - "modified_by_id" - ], - "columnsTo": [ - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.web_test": { - "name": "web_test", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "web_test_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "text": { - "name": "text", - "type": "varchar", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "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 0c08a93..f00c69c 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -96,15 +96,8 @@ { "idx": 13, "version": "7", - "when": 1780355099953, - "tag": "0013_oval_dreaming_celestial", - "breakpoints": true - }, - { - "idx": 14, - "version": "7", - "when": 1780583898564, - "tag": "0014_remarkable_synch", + "when": 1781815592697, + "tag": "0013_youthful_captain_britain", "breakpoints": true } ] diff --git a/package.json b/package.json index b426338..c228315 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "backend", - "version": "0.16.0", + "version": "0.16.2", "description": "PoliNetwork backend server", "private": true, "keywords": [], @@ -64,4 +64,4 @@ "socket.io": "^4.8.3", "zod": "^4.1.11" } -} +} \ No newline at end of file diff --git a/package/package.json b/package/package.json index 682c0ff..24362b8 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,6 @@ { "name": "@polinetwork/backend", - "version": "0.16.0", - + "version": "0.16.2", "description": "Utils to interact with the backend.", "repository": { "type": "git", @@ -35,4 +34,4 @@ "devDependencies": { "typescript": "^5.9.2" } -} +} \ No newline at end of file diff --git a/src/db/schema/web/index.ts b/src/db/schema/web/index.ts index ffa0ddf..802418e 100644 --- a/src/db/schema/web/index.ts +++ b/src/db/schema/web/index.ts @@ -1,4 +1,5 @@ import * as faqs from "./faqs" +import * as projects from "./projects" import * as test from "./test" -export const schema = { ...test, ...faqs } +export const schema = { ...test, ...faqs, ...projects } diff --git a/src/db/schema/web/projects.ts b/src/db/schema/web/projects.ts new file mode 100644 index 0000000..0dadd18 --- /dev/null +++ b/src/db/schema/web/projects.ts @@ -0,0 +1,24 @@ +import { bigint, integer, text } from "drizzle-orm/pg-core" +import { timeColumns } from "@/db/columns" +import { createTable } from "../create-table" +import { permissions } from "../tg/permissions" + +export const projectsCategories = ["news", "deprecated", "general"] as const + +export type ProjectCategory = (typeof projectsCategories)[number] + +export const projects = createTable.web("projects", { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + title: text("title").notNull(), + descriptionIt: text("description_it").notNull(), + descriptionEn: text("description_en").notNull(), + logo: text("logo"), + link: text("link"), + category: text("category", { enum: projectsCategories }).notNull().default("general"), + order: integer("order").notNull().default(0), + createdBy: bigint("created_by_id", { mode: "number" }) + .references(() => permissions.userId) + .notNull(), + modifiedBy: bigint("modified_by_id", { mode: "number" }).references(() => permissions.userId), + ...timeColumns, +}) diff --git a/src/routers/index.ts b/src/routers/index.ts index 8c63456..5d399ca 100644 --- a/src/routers/index.ts +++ b/src/routers/index.ts @@ -1,9 +1,9 @@ +import { webRouter } from "@/routers/web" import { createTRPCRouter } from "@/trpc" import { authRouter } from "./auth" import { azureRouter } from "./azure" import { testRouter } from "./test" import { tgRouter } from "./tg" -import { webRouter } from "./web" /** * This is the primary router for your server. diff --git a/src/routers/web/index.ts b/src/routers/web/index.ts index c3ab5ef..63b0740 100644 --- a/src/routers/web/index.ts +++ b/src/routers/web/index.ts @@ -1,4 +1,5 @@ import { createTRPCRouter } from "@/trpc" import faqs from "./faqs" +import projects from "./projects" -export const webRouter = createTRPCRouter({ faqs }) +export const webRouter = createTRPCRouter({ faqs, projects }) diff --git a/src/routers/web/projects.ts b/src/routers/web/projects.ts new file mode 100644 index 0000000..f201860 --- /dev/null +++ b/src/routers/web/projects.ts @@ -0,0 +1,96 @@ +import { asc, eq } from "drizzle-orm" +import z from "zod" +import { DB, SCHEMA } from "@/db" +import { projectsCategories } from "@/db/schema/web/projects" +import { createTRPCRouter, publicProcedure } from "@/trpc" + +const PROJECTS = SCHEMA.WEB.projects + +const projectSchema = z.object({ + id: z.number(), + title: z.string(), + descriptionIt: z.string(), + descriptionEn: z.string(), + logo: z.string().nullable(), + link: z.string().nullable(), + category: z.enum(projectsCategories), +}) + +export default createTRPCRouter({ + getAllProjects: publicProcedure.output(z.array(projectSchema)).query(async () => { + return await DB.select().from(PROJECTS).orderBy(asc(PROJECTS.order)) + }), + + addProject: publicProcedure + .input(projectSchema.omit({ id: true }).extend({ createdBy: z.number() })) + .mutation(async ({ input }) => { + const { title, descriptionIt, descriptionEn, logo, link, category, createdBy } = input + + const [res] = await DB.insert(PROJECTS) + .values({ + title, + descriptionIt, + descriptionEn, + logo, + link, + category, + createdBy, + }) + .returning() + + return res + }), + + editProject: publicProcedure.input(projectSchema.extend({ modifiedBy: z.number() })).mutation(async ({ input }) => { + const { id, title, descriptionIt, descriptionEn, logo, link, category, modifiedBy } = input + + const [res] = await DB.update(PROJECTS) + .set({ + title, + descriptionIt, + descriptionEn, + logo, + link, + category, + modifiedBy, + }) + .where(eq(PROJECTS.id, id)) + .returning() + + if (!res) return { error: "NOT_FOUND" } + return res + }), + + reorderProjects: publicProcedure + .input( + z.object({ + projectIds: z + .array(z.number().int()) + .min(1) + .refine((projectIds) => new Set(projectIds).size === projectIds.length), + }) + ) + .mutation(async ({ input }) => { + await DB.transaction(async (tx) => { + await Promise.all( + input.projectIds.map((id, index) => tx.update(PROJECTS).set({ order: index }).where(eq(PROJECTS.id, id))) + ) + }) + + return { error: null } + }), + + deleteProject: publicProcedure + .input( + z.object({ + id: z.number(), + }) + ) + .mutation(async ({ input }) => { + const { id } = input + const deleted = await DB.delete(PROJECTS).where(eq(PROJECTS.id, id)).returning() + + if (deleted.length === 0) return { error: "NOT_FOUND" } + return { error: null } + }), +})