From dcfc4e1ab47e8d221fb0ef2a9960e863a62aed5d Mon Sep 17 00:00:00 2001 From: Flip van Haaren Date: Wed, 29 Jan 2025 10:47:55 +0100 Subject: [PATCH] Refactor/auth (#360) * refactor: replace oslo/password * refactor sessions * refactor permission manager, type for actions * refactor auth flows * check token using id not token itself * do not leak session token in /me * fix happy path --- backend/.env.example | 3 + backend/drizzle/0000_lowly_husk.sql | 239 ---- .../drizzle/0000_outstanding_titanium_man.sql | 165 +++ backend/drizzle/0001_gray_the_executioner.sql | 2 - .../drizzle/0002_sticky_cassandra_nova.sql | 2 - backend/drizzle/0003_nasty_jigsaw.sql | 2 - backend/drizzle/meta/0000_snapshot.json | 107 +- backend/drizzle/meta/0001_snapshot.json | 1187 ---------------- backend/drizzle/meta/0002_snapshot.json | 1193 ---------------- backend/drizzle/meta/0003_snapshot.json | 1213 ----------------- backend/drizzle/meta/_journal.json | 25 +- backend/emails/README.md | 6 + backend/emails/components/avatar.tsx | 1 + backend/emails/components/user-name.tsx | 20 - backend/emails/create-password.tsx | 26 +- backend/emails/email-verification.tsx | 3 +- backend/emails/member-invite.tsx | 13 +- backend/emails/newsletter.tsx | 2 +- backend/emails/system-invite.tsx | 14 +- backend/env.ts | 1 + backend/package.json | 19 +- backend/scripts/drizzle-studio.ts | 4 + backend/scripts/seeds/organizations/seed.ts | 4 +- backend/scripts/seeds/user/seed.ts | 9 +- backend/src/db/lucia.ts | 54 - backend/src/db/schema/sessions.ts | 4 +- backend/src/db/schema/tokens.ts | 8 +- backend/src/db/schema/users.ts | 9 +- backend/src/lib/context.ts | 12 +- backend/src/lib/errors.ts | 8 +- backend/src/lib/i18n-locales.ts | 1 + backend/src/lib/imado-url.ts | 5 +- backend/src/middlewares/README.md | 12 +- backend/src/middlewares/guard/index.ts | 6 +- .../src/middlewares/guard/is-authenticated.ts | 27 +- backend/src/middlewares/has-valid-token.ts | 30 + backend/src/modules/README.md | 2 +- backend/src/modules/attachments/index.ts | 12 +- backend/src/modules/attachments/routes.ts | 4 +- backend/src/modules/auth/helpers/argon2id.ts | 29 +- backend/src/modules/auth/helpers/cookie.ts | 48 + backend/src/modules/auth/helpers/cookies.ts | 85 -- .../modules/auth/helpers/oauth-providers.ts | 75 + backend/src/modules/auth/helpers/oauth.ts | 77 +- backend/src/modules/auth/helpers/session.ts | 107 ++ backend/src/modules/auth/helpers/user.ts | 72 +- .../src/modules/auth/helpers/verify-email.ts | 5 +- backend/src/modules/auth/index.ts | 915 ++++++------- backend/src/modules/auth/routes.ts | 147 +- backend/src/modules/auth/schema.ts | 26 +- backend/src/modules/general/index.ts | 39 +- backend/src/modules/general/schema.ts | 3 +- .../src/modules/me/helpers/get-sessions.ts | 17 +- backend/src/modules/me/index.ts | 39 +- backend/src/modules/memberships/index.ts | 56 +- backend/src/modules/organizations/index.ts | 12 +- backend/src/modules/requests/index.ts | 4 +- backend/src/modules/users/index.ts | 24 +- backend/src/modules/users/schema.ts | 1 - backend/src/permissions/README.md | 1 + backend/src/permissions/get-valid-entity.ts | 41 + .../permission-manager.ts | 48 +- .../split-by-allowance.ts | 8 +- backend/src/types/app.ts | 6 +- backend/src/utils/nanoid.ts | 2 +- backend/src/utils/time-span.ts | 48 + config/default.ts | 7 +- .../public/static/images/features/lucia.svg | 2 +- ...ccept-invite.tsx => accept-org-invite.tsx} | 48 +- frontend/src/modules/auth/api.ts | 53 +- frontend/src/modules/auth/auth-notice.tsx | 41 + frontend/src/modules/auth/auth-steps.tsx | 28 +- .../src/modules/auth/create-password-form.tsx | 80 +- ...erification.tsx => email-verification.tsx} | 5 +- frontend/src/modules/auth/oauth-options.tsx | 42 +- frontend/src/modules/auth/query-mutations.ts | 9 + frontend/src/modules/auth/query.ts | 1 + frontend/src/modules/auth/sign-in-form.tsx | 36 +- frontend/src/modules/auth/sign-out.tsx | 1 + frontend/src/modules/auth/sign-up-form.tsx | 50 +- frontend/src/modules/auth/verify-email.tsx | 28 +- frontend/src/modules/auth/waitlist-form.tsx | 14 +- frontend/src/modules/common/error-notice.tsx | 84 +- frontend/src/modules/common/text-effect.tsx | 4 +- .../src/modules/general/query-mutations.ts | 24 +- frontend/src/modules/general/query.ts | 2 +- .../src/modules/home/onboarding/index.tsx | 3 +- .../src/modules/home/onboarding/start.tsx | 4 +- .../modules/marketing/about/about-config.tsx | 11 + .../src/modules/marketing/about/features.tsx | 12 +- frontend/src/modules/users/helpers.tsx | 39 +- frontend/src/modules/users/session-tile.tsx | 2 +- frontend/src/modules/users/settings-page.tsx | 32 +- .../src/modules/users/update-user-form.tsx | 2 - frontend/src/routes/auth.tsx | 27 +- frontend/src/routes/index.tsx | 8 +- info/ARCHITECTURE.md | 13 +- locales/en/about.json | 18 +- locales/en/backend.json | 12 +- locales/en/common.json | 5 +- locales/en/errors.json | 13 +- package.json | 2 +- pnpm-lock.yaml | 1124 ++++++++------- 103 files changed, 2430 insertions(+), 5845 deletions(-) delete mode 100644 backend/drizzle/0000_lowly_husk.sql create mode 100644 backend/drizzle/0000_outstanding_titanium_man.sql delete mode 100644 backend/drizzle/0001_gray_the_executioner.sql delete mode 100644 backend/drizzle/0002_sticky_cassandra_nova.sql delete mode 100644 backend/drizzle/0003_nasty_jigsaw.sql delete mode 100644 backend/drizzle/meta/0001_snapshot.json delete mode 100644 backend/drizzle/meta/0002_snapshot.json delete mode 100644 backend/drizzle/meta/0003_snapshot.json create mode 100644 backend/emails/README.md delete mode 100644 backend/emails/components/user-name.tsx delete mode 100644 backend/src/db/lucia.ts create mode 100644 backend/src/middlewares/has-valid-token.ts create mode 100644 backend/src/modules/auth/helpers/cookie.ts delete mode 100644 backend/src/modules/auth/helpers/cookies.ts create mode 100644 backend/src/modules/auth/helpers/oauth-providers.ts create mode 100644 backend/src/modules/auth/helpers/session.ts create mode 100644 backend/src/permissions/README.md create mode 100644 backend/src/permissions/get-valid-entity.ts rename backend/src/{lib => permissions}/permission-manager.ts (61%) rename backend/src/{utils => permissions}/split-by-allowance.ts (67%) create mode 100644 backend/src/utils/time-span.ts rename frontend/src/modules/auth/{accept-invite.tsx => accept-org-invite.tsx} (59%) create mode 100644 frontend/src/modules/auth/auth-notice.tsx rename frontend/src/modules/auth/{request-verification.tsx => email-verification.tsx} (70%) diff --git a/backend/.env.example b/backend/.env.example index 6d1d90a22..e87d1be74 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -13,6 +13,9 @@ UNSUBSCRIBE_TOKEN_SECRET=some_secret_token # Secret for argon2id password (required) ARGON_SECRET=argon_two_secret +# Secret for cookies (required) +COOKIE_SECRET=cookie_secret + # Remote system access IP (required) (for multiple IPs, separate by comma) REMOTE_SYSTEM_ACCESS_IP=* diff --git a/backend/drizzle/0000_lowly_husk.sql b/backend/drizzle/0000_lowly_husk.sql deleted file mode 100644 index 0590dc62e..000000000 --- a/backend/drizzle/0000_lowly_husk.sql +++ /dev/null @@ -1,239 +0,0 @@ -CREATE TABLE IF NOT EXISTS "attachments" ( - "id" varchar PRIMARY KEY NOT NULL, - "name" varchar DEFAULT 'attachment' NOT NULL, - "filename" varchar NOT NULL, - "content_type" varchar NOT NULL, - "size" varchar NOT NULL, - "entity" varchar DEFAULT 'attachment' NOT NULL, - "url" varchar NOT NULL, - "created_at" timestamp DEFAULT now() NOT NULL, - "created_by" varchar, - "modified_at" timestamp, - "modified_by" varchar, - "organization_id" varchar NOT NULL -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "memberships" ( - "id" varchar PRIMARY KEY NOT NULL, - "type" varchar NOT NULL, - "user_id" varchar NOT NULL, - "role" varchar DEFAULT 'member' NOT NULL, - "created_at" timestamp DEFAULT now() NOT NULL, - "created_by" varchar, - "modified_at" timestamp, - "modified_by" varchar, - "archived" boolean DEFAULT false NOT NULL, - "muted" boolean DEFAULT false NOT NULL, - "order" double precision NOT NULL, - "organization_id" varchar NOT NULL -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "oauth_accounts" ( - "provider_id" varchar NOT NULL, - "provider_user_id" varchar NOT NULL, - "user_id" varchar NOT NULL, - "created_at" timestamp DEFAULT now() NOT NULL, - CONSTRAINT "oauth_accounts_provider_id_provider_user_id_pk" PRIMARY KEY("provider_id","provider_user_id") -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "organizations" ( - "id" varchar PRIMARY KEY NOT NULL, - "entity" varchar DEFAULT 'organization' NOT NULL, - "name" varchar NOT NULL, - "short_name" varchar, - "slug" varchar NOT NULL, - "country" varchar, - "timezone" varchar, - "default_language" varchar DEFAULT 'en' NOT NULL, - "languages" json DEFAULT '["en"]'::json NOT NULL, - "notification_email" varchar, - "email_domains" json DEFAULT '[]'::json NOT NULL, - "color" varchar, - "thumbnail_url" varchar, - "banner_url" varchar, - "logo_url" varchar, - "website_url" varchar, - "welcome_text" varchar, - "auth_strategies" json DEFAULT '[]'::json NOT NULL, - "chat_support" boolean DEFAULT false NOT NULL, - "created_at" timestamp DEFAULT now() NOT NULL, - "created_by" varchar, - "modified_at" timestamp, - "modified_by" varchar, - CONSTRAINT "organizations_slug_unique" UNIQUE("slug") -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "passkeys" ( - "id" varchar PRIMARY KEY NOT NULL, - "user_email" varchar NOT NULL, - "credential_id" varchar NOT NULL, - "public_key" varchar NOT NULL, - "created_at" timestamp DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "requests" ( - "id" varchar PRIMARY KEY NOT NULL, - "message" varchar, - "email" varchar NOT NULL, - "type" varchar NOT NULL, - "created_at" timestamp DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "sessions" ( - "id" varchar PRIMARY KEY NOT NULL, - "user_id" varchar NOT NULL, - "device_name" varchar, - "device_type" varchar DEFAULT 'desktop' NOT NULL, - "device_os" varchar, - "browser" varchar, - "auth_strategy" varchar, - "type" varchar DEFAULT 'regular' NOT NULL, - "created_at" timestamp DEFAULT now() NOT NULL, - "expires_at" timestamp with time zone NOT NULL, - "admin_user_id" varchar -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "tokens" ( - "id" varchar PRIMARY KEY NOT NULL, - "type" varchar NOT NULL, - "email" varchar, - "role" varchar, - "user_id" varchar, - "organization_id" varchar, - "created_at" timestamp DEFAULT now() NOT NULL, - "expires_at" timestamp with time zone NOT NULL -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "users" ( - "id" varchar PRIMARY KEY NOT NULL, - "entity" varchar DEFAULT 'user' NOT NULL, - "hashed_password" varchar, - "slug" varchar NOT NULL, - "unsubscribe_token" varchar NOT NULL, - "name" varchar NOT NULL, - "first_name" varchar, - "last_name" varchar, - "email" varchar NOT NULL, - "email_verified" boolean DEFAULT false NOT NULL, - "bio" varchar, - "language" varchar DEFAULT 'en' NOT NULL, - "banner_url" varchar, - "thumbnail_url" varchar, - "newsletter" boolean DEFAULT false NOT NULL, - "last_seen_at" timestamp, - "last_started_at" timestamp, - "last_sign_in_at" timestamp, - "created_at" timestamp DEFAULT now() NOT NULL, - "modified_at" timestamp, - "modified_by" varchar, - "role" varchar DEFAULT 'user' NOT NULL, - CONSTRAINT "users_slug_unique" UNIQUE("slug"), - CONSTRAINT "users_unsubscribeToken_unique" UNIQUE("unsubscribe_token"), - CONSTRAINT "users_email_unique" UNIQUE("email") -); ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "attachments" ADD CONSTRAINT "attachments_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "attachments" ADD CONSTRAINT "attachments_modified_by_users_id_fk" FOREIGN KEY ("modified_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "attachments" ADD CONSTRAINT "attachments_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "memberships" ADD CONSTRAINT "memberships_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "memberships" ADD CONSTRAINT "memberships_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "memberships" ADD CONSTRAINT "memberships_modified_by_users_id_fk" FOREIGN KEY ("modified_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "memberships" ADD CONSTRAINT "memberships_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "oauth_accounts" ADD CONSTRAINT "oauth_accounts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "organizations" ADD CONSTRAINT "organizations_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "organizations" ADD CONSTRAINT "organizations_modified_by_users_id_fk" FOREIGN KEY ("modified_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "passkeys" ADD CONSTRAINT "passkeys_user_email_users_email_fk" FOREIGN KEY ("user_email") REFERENCES "public"."users"("email") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "sessions" ADD CONSTRAINT "sessions_admin_user_id_users_id_fk" FOREIGN KEY ("admin_user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "tokens" ADD CONSTRAINT "tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "tokens" ADD CONSTRAINT "tokens_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "users" ADD CONSTRAINT "users_modified_by_users_id_fk" FOREIGN KEY ("modified_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -CREATE INDEX IF NOT EXISTS "organizations_name_index" ON "organizations" USING btree ("name" DESC NULLS LAST);--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "organizations_created_at_index" ON "organizations" USING btree ("created_at" DESC NULLS LAST);--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "requests_emails" ON "requests" USING btree ("email" DESC NULLS LAST);--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "requests_created_at" ON "requests" USING btree ("created_at" DESC NULLS LAST);--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "idx_admin_id" ON "sessions" USING btree ("admin_user_id");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "users_name_index" ON "users" USING btree ("name" DESC NULLS LAST);--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "users_token_index" ON "users" USING btree ("unsubscribe_token");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "users_email_index" ON "users" USING btree ("email" DESC NULLS LAST);--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "users_created_at_index" ON "users" USING btree ("created_at" DESC NULLS LAST); \ No newline at end of file diff --git a/backend/drizzle/0000_outstanding_titanium_man.sql b/backend/drizzle/0000_outstanding_titanium_man.sql new file mode 100644 index 000000000..53a200202 --- /dev/null +++ b/backend/drizzle/0000_outstanding_titanium_man.sql @@ -0,0 +1,165 @@ +CREATE TABLE "attachments" ( + "id" varchar PRIMARY KEY NOT NULL, + "name" varchar DEFAULT 'attachment' NOT NULL, + "filename" varchar NOT NULL, + "content_type" varchar NOT NULL, + "size" varchar NOT NULL, + "entity" varchar DEFAULT 'attachment' NOT NULL, + "url" varchar NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + "created_by" varchar, + "modified_at" timestamp, + "modified_by" varchar, + "organization_id" varchar NOT NULL +); +--> statement-breakpoint +CREATE TABLE "memberships" ( + "id" varchar PRIMARY KEY NOT NULL, + "type" varchar NOT NULL, + "user_id" varchar NOT NULL, + "role" varchar DEFAULT 'member' NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + "created_by" varchar, + "modified_at" timestamp, + "modified_by" varchar, + "archived" boolean DEFAULT false NOT NULL, + "muted" boolean DEFAULT false NOT NULL, + "order" double precision NOT NULL, + "organization_id" varchar NOT NULL +); +--> statement-breakpoint +CREATE TABLE "oauth_accounts" ( + "provider_id" varchar NOT NULL, + "provider_user_id" varchar NOT NULL, + "user_id" varchar NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "oauth_accounts_provider_id_provider_user_id_pk" PRIMARY KEY("provider_id","provider_user_id") +); +--> statement-breakpoint +CREATE TABLE "organizations" ( + "id" varchar PRIMARY KEY NOT NULL, + "entity" varchar DEFAULT 'organization' NOT NULL, + "name" varchar NOT NULL, + "short_name" varchar, + "slug" varchar NOT NULL, + "country" varchar, + "timezone" varchar, + "default_language" varchar DEFAULT 'en' NOT NULL, + "languages" json DEFAULT '["en"]'::json NOT NULL, + "notification_email" varchar, + "email_domains" json DEFAULT '[]'::json NOT NULL, + "color" varchar, + "thumbnail_url" varchar, + "banner_url" varchar, + "logo_url" varchar, + "website_url" varchar, + "welcome_text" varchar, + "auth_strategies" json DEFAULT '[]'::json NOT NULL, + "chat_support" boolean DEFAULT false NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + "created_by" varchar, + "modified_at" timestamp, + "modified_by" varchar, + CONSTRAINT "organizations_slug_unique" UNIQUE("slug") +); +--> statement-breakpoint +CREATE TABLE "passkeys" ( + "id" varchar PRIMARY KEY NOT NULL, + "user_email" varchar NOT NULL, + "credential_id" varchar NOT NULL, + "public_key" varchar NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "requests" ( + "id" varchar PRIMARY KEY NOT NULL, + "message" varchar, + "email" varchar NOT NULL, + "type" varchar NOT NULL, + "token" varchar, + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "sessions" ( + "id" varchar PRIMARY KEY NOT NULL, + "token" varchar NOT NULL, + "user_id" varchar NOT NULL, + "device_name" varchar, + "device_type" varchar DEFAULT 'desktop' NOT NULL, + "device_os" varchar, + "browser" varchar, + "auth_strategy" varchar, + "type" varchar DEFAULT 'regular' NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + "expires_at" timestamp with time zone NOT NULL, + "admin_user_id" varchar +); +--> statement-breakpoint +CREATE TABLE "tokens" ( + "id" varchar PRIMARY KEY NOT NULL, + "token" varchar NOT NULL, + "type" varchar NOT NULL, + "email" varchar NOT NULL, + "role" varchar, + "user_id" varchar, + "organization_id" varchar, + "created_at" timestamp DEFAULT now() NOT NULL, + "created_by" varchar, + "expires_at" timestamp with time zone NOT NULL, + "membership_info" json +); +--> statement-breakpoint +CREATE TABLE "users" ( + "id" varchar PRIMARY KEY NOT NULL, + "entity" varchar DEFAULT 'user' NOT NULL, + "hashed_password" varchar, + "slug" varchar NOT NULL, + "unsubscribe_token" varchar NOT NULL, + "name" varchar NOT NULL, + "first_name" varchar, + "last_name" varchar, + "email" varchar NOT NULL, + "email_verified" boolean DEFAULT false NOT NULL, + "language" varchar DEFAULT 'en' NOT NULL, + "banner_url" varchar, + "thumbnail_url" varchar, + "newsletter" boolean DEFAULT false NOT NULL, + "last_seen_at" timestamp, + "last_started_at" timestamp, + "last_sign_in_at" timestamp, + "created_at" timestamp DEFAULT now() NOT NULL, + "modified_at" timestamp, + "modified_by" varchar, + "role" varchar DEFAULT 'user' NOT NULL, + CONSTRAINT "users_slug_unique" UNIQUE("slug"), + CONSTRAINT "users_unsubscribeToken_unique" UNIQUE("unsubscribe_token"), + CONSTRAINT "users_email_unique" UNIQUE("email") +); +--> statement-breakpoint +ALTER TABLE "attachments" ADD CONSTRAINT "attachments_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "attachments" ADD CONSTRAINT "attachments_modified_by_users_id_fk" FOREIGN KEY ("modified_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "attachments" ADD CONSTRAINT "attachments_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "memberships" ADD CONSTRAINT "memberships_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "memberships" ADD CONSTRAINT "memberships_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "memberships" ADD CONSTRAINT "memberships_modified_by_users_id_fk" FOREIGN KEY ("modified_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "memberships" ADD CONSTRAINT "memberships_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "oauth_accounts" ADD CONSTRAINT "oauth_accounts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "organizations" ADD CONSTRAINT "organizations_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "organizations" ADD CONSTRAINT "organizations_modified_by_users_id_fk" FOREIGN KEY ("modified_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "passkeys" ADD CONSTRAINT "passkeys_user_email_users_email_fk" FOREIGN KEY ("user_email") REFERENCES "public"."users"("email") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "requests" ADD CONSTRAINT "requests_token_tokens_id_fk" FOREIGN KEY ("token") REFERENCES "public"."tokens"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "sessions" ADD CONSTRAINT "sessions_admin_user_id_users_id_fk" FOREIGN KEY ("admin_user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "tokens" ADD CONSTRAINT "tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "tokens" ADD CONSTRAINT "tokens_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "tokens" ADD CONSTRAINT "tokens_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "users" ADD CONSTRAINT "users_modified_by_users_id_fk" FOREIGN KEY ("modified_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +CREATE INDEX "organizations_name_index" ON "organizations" USING btree ("name" DESC NULLS LAST);--> statement-breakpoint +CREATE INDEX "organizations_created_at_index" ON "organizations" USING btree ("created_at" DESC NULLS LAST);--> statement-breakpoint +CREATE INDEX "requests_emails" ON "requests" USING btree ("email" DESC NULLS LAST);--> statement-breakpoint +CREATE INDEX "requests_created_at" ON "requests" USING btree ("created_at" DESC NULLS LAST);--> statement-breakpoint +CREATE INDEX "idx_admin_id" ON "sessions" USING btree ("admin_user_id");--> statement-breakpoint +CREATE INDEX "users_name_index" ON "users" USING btree ("name" DESC NULLS LAST);--> statement-breakpoint +CREATE INDEX "users_token_index" ON "users" USING btree ("unsubscribe_token");--> statement-breakpoint +CREATE INDEX "users_email_index" ON "users" USING btree ("email" DESC NULLS LAST);--> statement-breakpoint +CREATE INDEX "users_created_at_index" ON "users" USING btree ("created_at" DESC NULLS LAST); \ No newline at end of file diff --git a/backend/drizzle/0001_gray_the_executioner.sql b/backend/drizzle/0001_gray_the_executioner.sql deleted file mode 100644 index ab7287ef2..000000000 --- a/backend/drizzle/0001_gray_the_executioner.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "tokens" ADD COLUMN "created_by" varchar;--> statement-breakpoint -ALTER TABLE "tokens" ADD CONSTRAINT "tokens_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action; \ No newline at end of file diff --git a/backend/drizzle/0002_sticky_cassandra_nova.sql b/backend/drizzle/0002_sticky_cassandra_nova.sql deleted file mode 100644 index fa5f4ef3e..000000000 --- a/backend/drizzle/0002_sticky_cassandra_nova.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "tokens" ALTER COLUMN "email" SET NOT NULL;--> statement-breakpoint -ALTER TABLE "tokens" ADD COLUMN "membership_info" json; \ No newline at end of file diff --git a/backend/drizzle/0003_nasty_jigsaw.sql b/backend/drizzle/0003_nasty_jigsaw.sql deleted file mode 100644 index b9a7755a4..000000000 --- a/backend/drizzle/0003_nasty_jigsaw.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "requests" ADD COLUMN "token" varchar;--> statement-breakpoint -ALTER TABLE "requests" ADD CONSTRAINT "requests_token_tokens_id_fk" FOREIGN KEY ("token") REFERENCES "public"."tokens"("id") ON DELETE cascade ON UPDATE no action; \ No newline at end of file diff --git a/backend/drizzle/meta/0000_snapshot.json b/backend/drizzle/meta/0000_snapshot.json index ab5c0a1d1..b9d3390e9 100644 --- a/backend/drizzle/meta/0000_snapshot.json +++ b/backend/drizzle/meta/0000_snapshot.json @@ -1,5 +1,5 @@ { - "id": "f9ab7262-683f-420e-b7cb-31bf121650bc", + "id": "403062a9-ffe9-4dc6-ab05-a5b5dfd35be9", "prevId": "00000000-0000-0000-0000-000000000000", "version": "7", "dialect": "postgresql", @@ -128,7 +128,9 @@ }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, - "checkConstraints": {} + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false }, "public.memberships": { "name": "memberships", @@ -268,7 +270,9 @@ }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, - "checkConstraints": {} + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false }, "public.oauth_accounts": { "name": "oauth_accounts", @@ -326,7 +330,9 @@ } }, "uniqueConstraints": {}, - "checkConstraints": {} + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false }, "public.organizations": { "name": "organizations", @@ -548,7 +554,9 @@ ] } }, - "checkConstraints": {} + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false }, "public.passkeys": { "name": "passkeys", @@ -604,7 +612,9 @@ }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, - "checkConstraints": {} + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false }, "public.requests": { "name": "requests", @@ -634,6 +644,12 @@ "primaryKey": false, "notNull": true }, + "token": { + "name": "token", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, "created_at": { "name": "created_at", "type": "timestamp", @@ -674,10 +690,26 @@ "with": {} } }, - "foreignKeys": {}, + "foreignKeys": { + "requests_token_tokens_id_fk": { + "name": "requests_token_tokens_id_fk", + "tableFrom": "requests", + "tableTo": "tokens", + "columnsFrom": [ + "token" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, - "checkConstraints": {} + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false }, "public.sessions": { "name": "sessions", @@ -689,6 +721,12 @@ "primaryKey": true, "notNull": true }, + "token": { + "name": "token", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, "user_id": { "name": "user_id", "type": "varchar", @@ -800,7 +838,9 @@ }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, - "checkConstraints": {} + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false }, "public.tokens": { "name": "tokens", @@ -812,6 +852,12 @@ "primaryKey": true, "notNull": true }, + "token": { + "name": "token", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, "type": { "name": "type", "type": "varchar", @@ -822,7 +868,7 @@ "name": "email", "type": "varchar", "primaryKey": false, - "notNull": false + "notNull": true }, "role": { "name": "role", @@ -849,11 +895,23 @@ "notNull": true, "default": "now()" }, + "created_by": { + "name": "created_by", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, "expires_at": { "name": "expires_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true + }, + "membership_info": { + "name": "membership_info", + "type": "json", + "primaryKey": false, + "notNull": false } }, "indexes": {}, @@ -883,11 +941,26 @@ ], "onDelete": "cascade", "onUpdate": "no action" + }, + "tokens_created_by_users_id_fk": { + "name": "tokens_created_by_users_id_fk", + "tableFrom": "tokens", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, - "checkConstraints": {} + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false }, "public.users": { "name": "users", @@ -955,12 +1028,6 @@ "notNull": true, "default": false }, - "bio": { - "name": "bio", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, "language": { "name": "language", "type": "varchar", @@ -1133,12 +1200,16 @@ ] } }, - "checkConstraints": {} + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false } }, "enums": {}, "schemas": {}, "sequences": {}, + "roles": {}, + "policies": {}, "views": {}, "_meta": { "columns": {}, diff --git a/backend/drizzle/meta/0001_snapshot.json b/backend/drizzle/meta/0001_snapshot.json deleted file mode 100644 index f4e7cc36e..000000000 --- a/backend/drizzle/meta/0001_snapshot.json +++ /dev/null @@ -1,1187 +0,0 @@ -{ - "id": "7dbcd0d1-aee0-4c98-b0bb-523fb1a2abf1", - "prevId": "f9ab7262-683f-420e-b7cb-31bf121650bc", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.attachments": { - "name": "attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'attachment'" - }, - "filename": { - "name": "filename", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "content_type": { - "name": "content_type", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "size": { - "name": "size", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "entity": { - "name": "entity", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'attachment'" - }, - "url": { - "name": "url", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "modified_at": { - "name": "modified_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "modified_by": { - "name": "modified_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "organization_id": { - "name": "organization_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "attachments_created_by_users_id_fk": { - "name": "attachments_created_by_users_id_fk", - "tableFrom": "attachments", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "attachments_modified_by_users_id_fk": { - "name": "attachments_modified_by_users_id_fk", - "tableFrom": "attachments", - "tableTo": "users", - "columnsFrom": [ - "modified_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "attachments_organization_id_organizations_id_fk": { - "name": "attachments_organization_id_organizations_id_fk", - "tableFrom": "attachments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "type": { - "name": "type", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'member'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "modified_at": { - "name": "modified_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "modified_by": { - "name": "modified_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "archived": { - "name": "archived", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "muted": { - "name": "muted", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "order": { - "name": "order", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_created_by_users_id_fk": { - "name": "memberships_created_by_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "memberships_modified_by_users_id_fk": { - "name": "memberships_modified_by_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "modified_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.oauth_accounts": { - "name": "oauth_accounts", - "schema": "", - "columns": { - "provider_id": { - "name": "provider_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "oauth_accounts_user_id_users_id_fk": { - "name": "oauth_accounts_user_id_users_id_fk", - "tableFrom": "oauth_accounts", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "oauth_accounts_provider_id_provider_user_id_pk": { - "name": "oauth_accounts_provider_id_provider_user_id_pk", - "columns": [ - "provider_id", - "provider_user_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "entity": { - "name": "entity", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'organization'" - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "short_name": { - "name": "short_name", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "slug": { - "name": "slug", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "country": { - "name": "country", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "timezone": { - "name": "timezone", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "default_language": { - "name": "default_language", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'en'" - }, - "languages": { - "name": "languages", - "type": "json", - "primaryKey": false, - "notNull": true, - "default": "'[\"en\"]'::json" - }, - "notification_email": { - "name": "notification_email", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "email_domains": { - "name": "email_domains", - "type": "json", - "primaryKey": false, - "notNull": true, - "default": "'[]'::json" - }, - "color": { - "name": "color", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "thumbnail_url": { - "name": "thumbnail_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "banner_url": { - "name": "banner_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "logo_url": { - "name": "logo_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "website_url": { - "name": "website_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "welcome_text": { - "name": "welcome_text", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "auth_strategies": { - "name": "auth_strategies", - "type": "json", - "primaryKey": false, - "notNull": true, - "default": "'[]'::json" - }, - "chat_support": { - "name": "chat_support", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "modified_at": { - "name": "modified_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "modified_by": { - "name": "modified_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "organizations_name_index": { - "name": "organizations_name_index", - "columns": [ - { - "expression": "name", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "organizations_created_at_index": { - "name": "organizations_created_at_index", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "organizations_modified_by_users_id_fk": { - "name": "organizations_modified_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "modified_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "organizations_slug_unique": { - "name": "organizations_slug_unique", - "nullsNotDistinct": false, - "columns": [ - "slug" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.passkeys": { - "name": "passkeys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "user_email": { - "name": "user_email", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "credential_id": { - "name": "credential_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "public_key": { - "name": "public_key", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "passkeys_user_email_users_email_fk": { - "name": "passkeys_user_email_users_email_fk", - "tableFrom": "passkeys", - "tableTo": "users", - "columnsFrom": [ - "user_email" - ], - "columnsTo": [ - "email" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.requests": { - "name": "requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "message": { - "name": "message", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "requests_emails": { - "name": "requests_emails", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "requests_created_at": { - "name": "requests_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.sessions": { - "name": "sessions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "device_name": { - "name": "device_name", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "device_type": { - "name": "device_type", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'desktop'" - }, - "device_os": { - "name": "device_os", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "browser": { - "name": "browser", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "auth_strategy": { - "name": "auth_strategy", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "type": { - "name": "type", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'regular'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "admin_user_id": { - "name": "admin_user_id", - "type": "varchar", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_admin_id": { - "name": "idx_admin_id", - "columns": [ - { - "expression": "admin_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "sessions_user_id_users_id_fk": { - "name": "sessions_user_id_users_id_fk", - "tableFrom": "sessions", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "sessions_admin_user_id_users_id_fk": { - "name": "sessions_admin_user_id_users_id_fk", - "tableFrom": "sessions", - "tableTo": "users", - "columnsFrom": [ - "admin_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tokens": { - "name": "tokens", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "type": { - "name": "type", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "role": { - "name": "role", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "organization_id": { - "name": "organization_id", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "tokens_user_id_users_id_fk": { - "name": "tokens_user_id_users_id_fk", - "tableFrom": "tokens", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "tokens_organization_id_organizations_id_fk": { - "name": "tokens_organization_id_organizations_id_fk", - "tableFrom": "tokens", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "tokens_created_by_users_id_fk": { - "name": "tokens_created_by_users_id_fk", - "tableFrom": "tokens", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "entity": { - "name": "entity", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "hashed_password": { - "name": "hashed_password", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "slug": { - "name": "slug", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "unsubscribe_token": { - "name": "unsubscribe_token", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "last_name": { - "name": "last_name", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "email_verified": { - "name": "email_verified", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "bio": { - "name": "bio", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "language": { - "name": "language", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'en'" - }, - "banner_url": { - "name": "banner_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "thumbnail_url": { - "name": "thumbnail_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "newsletter": { - "name": "newsletter", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "last_started_at": { - "name": "last_started_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "last_sign_in_at": { - "name": "last_sign_in_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "modified_at": { - "name": "modified_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "modified_by": { - "name": "modified_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "role": { - "name": "role", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'user'" - } - }, - "indexes": { - "users_name_index": { - "name": "users_name_index", - "columns": [ - { - "expression": "name", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_token_index": { - "name": "users_token_index", - "columns": [ - { - "expression": "unsubscribe_token", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_email_index": { - "name": "users_email_index", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_created_at_index": { - "name": "users_created_at_index", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "users_modified_by_users_id_fk": { - "name": "users_modified_by_users_id_fk", - "tableFrom": "users", - "tableTo": "users", - "columnsFrom": [ - "modified_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "users_slug_unique": { - "name": "users_slug_unique", - "nullsNotDistinct": false, - "columns": [ - "slug" - ] - }, - "users_unsubscribeToken_unique": { - "name": "users_unsubscribeToken_unique", - "nullsNotDistinct": false, - "columns": [ - "unsubscribe_token" - ] - }, - "users_email_unique": { - "name": "users_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/backend/drizzle/meta/0002_snapshot.json b/backend/drizzle/meta/0002_snapshot.json deleted file mode 100644 index 6b2fdd7b5..000000000 --- a/backend/drizzle/meta/0002_snapshot.json +++ /dev/null @@ -1,1193 +0,0 @@ -{ - "id": "e20abb04-ff50-4770-8df2-780a756b1a99", - "prevId": "7dbcd0d1-aee0-4c98-b0bb-523fb1a2abf1", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.attachments": { - "name": "attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'attachment'" - }, - "filename": { - "name": "filename", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "content_type": { - "name": "content_type", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "size": { - "name": "size", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "entity": { - "name": "entity", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'attachment'" - }, - "url": { - "name": "url", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "modified_at": { - "name": "modified_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "modified_by": { - "name": "modified_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "organization_id": { - "name": "organization_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "attachments_created_by_users_id_fk": { - "name": "attachments_created_by_users_id_fk", - "tableFrom": "attachments", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "attachments_modified_by_users_id_fk": { - "name": "attachments_modified_by_users_id_fk", - "tableFrom": "attachments", - "tableTo": "users", - "columnsFrom": [ - "modified_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "attachments_organization_id_organizations_id_fk": { - "name": "attachments_organization_id_organizations_id_fk", - "tableFrom": "attachments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "type": { - "name": "type", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'member'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "modified_at": { - "name": "modified_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "modified_by": { - "name": "modified_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "archived": { - "name": "archived", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "muted": { - "name": "muted", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "order": { - "name": "order", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_created_by_users_id_fk": { - "name": "memberships_created_by_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "memberships_modified_by_users_id_fk": { - "name": "memberships_modified_by_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "modified_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.oauth_accounts": { - "name": "oauth_accounts", - "schema": "", - "columns": { - "provider_id": { - "name": "provider_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "oauth_accounts_user_id_users_id_fk": { - "name": "oauth_accounts_user_id_users_id_fk", - "tableFrom": "oauth_accounts", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "oauth_accounts_provider_id_provider_user_id_pk": { - "name": "oauth_accounts_provider_id_provider_user_id_pk", - "columns": [ - "provider_id", - "provider_user_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "entity": { - "name": "entity", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'organization'" - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "short_name": { - "name": "short_name", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "slug": { - "name": "slug", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "country": { - "name": "country", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "timezone": { - "name": "timezone", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "default_language": { - "name": "default_language", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'en'" - }, - "languages": { - "name": "languages", - "type": "json", - "primaryKey": false, - "notNull": true, - "default": "'[\"en\"]'::json" - }, - "notification_email": { - "name": "notification_email", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "email_domains": { - "name": "email_domains", - "type": "json", - "primaryKey": false, - "notNull": true, - "default": "'[]'::json" - }, - "color": { - "name": "color", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "thumbnail_url": { - "name": "thumbnail_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "banner_url": { - "name": "banner_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "logo_url": { - "name": "logo_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "website_url": { - "name": "website_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "welcome_text": { - "name": "welcome_text", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "auth_strategies": { - "name": "auth_strategies", - "type": "json", - "primaryKey": false, - "notNull": true, - "default": "'[]'::json" - }, - "chat_support": { - "name": "chat_support", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "modified_at": { - "name": "modified_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "modified_by": { - "name": "modified_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "organizations_name_index": { - "name": "organizations_name_index", - "columns": [ - { - "expression": "name", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "organizations_created_at_index": { - "name": "organizations_created_at_index", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "organizations_modified_by_users_id_fk": { - "name": "organizations_modified_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "modified_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "organizations_slug_unique": { - "name": "organizations_slug_unique", - "nullsNotDistinct": false, - "columns": [ - "slug" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.passkeys": { - "name": "passkeys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "user_email": { - "name": "user_email", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "credential_id": { - "name": "credential_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "public_key": { - "name": "public_key", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "passkeys_user_email_users_email_fk": { - "name": "passkeys_user_email_users_email_fk", - "tableFrom": "passkeys", - "tableTo": "users", - "columnsFrom": [ - "user_email" - ], - "columnsTo": [ - "email" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.requests": { - "name": "requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "message": { - "name": "message", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "requests_emails": { - "name": "requests_emails", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "requests_created_at": { - "name": "requests_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.sessions": { - "name": "sessions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "device_name": { - "name": "device_name", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "device_type": { - "name": "device_type", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'desktop'" - }, - "device_os": { - "name": "device_os", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "browser": { - "name": "browser", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "auth_strategy": { - "name": "auth_strategy", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "type": { - "name": "type", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'regular'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "admin_user_id": { - "name": "admin_user_id", - "type": "varchar", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_admin_id": { - "name": "idx_admin_id", - "columns": [ - { - "expression": "admin_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "sessions_user_id_users_id_fk": { - "name": "sessions_user_id_users_id_fk", - "tableFrom": "sessions", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "sessions_admin_user_id_users_id_fk": { - "name": "sessions_admin_user_id_users_id_fk", - "tableFrom": "sessions", - "tableTo": "users", - "columnsFrom": [ - "admin_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tokens": { - "name": "tokens", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "type": { - "name": "type", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "organization_id": { - "name": "organization_id", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "membership_info": { - "name": "membership_info", - "type": "json", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "tokens_user_id_users_id_fk": { - "name": "tokens_user_id_users_id_fk", - "tableFrom": "tokens", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "tokens_organization_id_organizations_id_fk": { - "name": "tokens_organization_id_organizations_id_fk", - "tableFrom": "tokens", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "tokens_created_by_users_id_fk": { - "name": "tokens_created_by_users_id_fk", - "tableFrom": "tokens", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "entity": { - "name": "entity", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "hashed_password": { - "name": "hashed_password", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "slug": { - "name": "slug", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "unsubscribe_token": { - "name": "unsubscribe_token", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "last_name": { - "name": "last_name", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "email_verified": { - "name": "email_verified", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "bio": { - "name": "bio", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "language": { - "name": "language", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'en'" - }, - "banner_url": { - "name": "banner_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "thumbnail_url": { - "name": "thumbnail_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "newsletter": { - "name": "newsletter", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "last_started_at": { - "name": "last_started_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "last_sign_in_at": { - "name": "last_sign_in_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "modified_at": { - "name": "modified_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "modified_by": { - "name": "modified_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "role": { - "name": "role", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'user'" - } - }, - "indexes": { - "users_name_index": { - "name": "users_name_index", - "columns": [ - { - "expression": "name", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_token_index": { - "name": "users_token_index", - "columns": [ - { - "expression": "unsubscribe_token", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_email_index": { - "name": "users_email_index", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_created_at_index": { - "name": "users_created_at_index", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "users_modified_by_users_id_fk": { - "name": "users_modified_by_users_id_fk", - "tableFrom": "users", - "tableTo": "users", - "columnsFrom": [ - "modified_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "users_slug_unique": { - "name": "users_slug_unique", - "nullsNotDistinct": false, - "columns": [ - "slug" - ] - }, - "users_unsubscribeToken_unique": { - "name": "users_unsubscribeToken_unique", - "nullsNotDistinct": false, - "columns": [ - "unsubscribe_token" - ] - }, - "users_email_unique": { - "name": "users_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/backend/drizzle/meta/0003_snapshot.json b/backend/drizzle/meta/0003_snapshot.json deleted file mode 100644 index 5afb79f59..000000000 --- a/backend/drizzle/meta/0003_snapshot.json +++ /dev/null @@ -1,1213 +0,0 @@ -{ - "id": "abdcc4bd-cf62-4b7e-acc7-981db200157f", - "prevId": "e20abb04-ff50-4770-8df2-780a756b1a99", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.attachments": { - "name": "attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'attachment'" - }, - "filename": { - "name": "filename", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "content_type": { - "name": "content_type", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "size": { - "name": "size", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "entity": { - "name": "entity", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'attachment'" - }, - "url": { - "name": "url", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "modified_at": { - "name": "modified_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "modified_by": { - "name": "modified_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "organization_id": { - "name": "organization_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "attachments_created_by_users_id_fk": { - "name": "attachments_created_by_users_id_fk", - "tableFrom": "attachments", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "attachments_modified_by_users_id_fk": { - "name": "attachments_modified_by_users_id_fk", - "tableFrom": "attachments", - "tableTo": "users", - "columnsFrom": [ - "modified_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "attachments_organization_id_organizations_id_fk": { - "name": "attachments_organization_id_organizations_id_fk", - "tableFrom": "attachments", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "type": { - "name": "type", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'member'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "modified_at": { - "name": "modified_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "modified_by": { - "name": "modified_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "archived": { - "name": "archived", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "muted": { - "name": "muted", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "order": { - "name": "order", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "memberships_user_id_users_id_fk": { - "name": "memberships_user_id_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "memberships_created_by_users_id_fk": { - "name": "memberships_created_by_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "memberships_modified_by_users_id_fk": { - "name": "memberships_modified_by_users_id_fk", - "tableFrom": "memberships", - "tableTo": "users", - "columnsFrom": [ - "modified_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "memberships_organization_id_organizations_id_fk": { - "name": "memberships_organization_id_organizations_id_fk", - "tableFrom": "memberships", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.oauth_accounts": { - "name": "oauth_accounts", - "schema": "", - "columns": { - "provider_id": { - "name": "provider_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "provider_user_id": { - "name": "provider_user_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "oauth_accounts_user_id_users_id_fk": { - "name": "oauth_accounts_user_id_users_id_fk", - "tableFrom": "oauth_accounts", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "oauth_accounts_provider_id_provider_user_id_pk": { - "name": "oauth_accounts_provider_id_provider_user_id_pk", - "columns": [ - "provider_id", - "provider_user_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "entity": { - "name": "entity", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'organization'" - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "short_name": { - "name": "short_name", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "slug": { - "name": "slug", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "country": { - "name": "country", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "timezone": { - "name": "timezone", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "default_language": { - "name": "default_language", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'en'" - }, - "languages": { - "name": "languages", - "type": "json", - "primaryKey": false, - "notNull": true, - "default": "'[\"en\"]'::json" - }, - "notification_email": { - "name": "notification_email", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "email_domains": { - "name": "email_domains", - "type": "json", - "primaryKey": false, - "notNull": true, - "default": "'[]'::json" - }, - "color": { - "name": "color", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "thumbnail_url": { - "name": "thumbnail_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "banner_url": { - "name": "banner_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "logo_url": { - "name": "logo_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "website_url": { - "name": "website_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "welcome_text": { - "name": "welcome_text", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "auth_strategies": { - "name": "auth_strategies", - "type": "json", - "primaryKey": false, - "notNull": true, - "default": "'[]'::json" - }, - "chat_support": { - "name": "chat_support", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "modified_at": { - "name": "modified_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "modified_by": { - "name": "modified_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "organizations_name_index": { - "name": "organizations_name_index", - "columns": [ - { - "expression": "name", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "organizations_created_at_index": { - "name": "organizations_created_at_index", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "organizations_created_by_users_id_fk": { - "name": "organizations_created_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "organizations_modified_by_users_id_fk": { - "name": "organizations_modified_by_users_id_fk", - "tableFrom": "organizations", - "tableTo": "users", - "columnsFrom": [ - "modified_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "organizations_slug_unique": { - "name": "organizations_slug_unique", - "nullsNotDistinct": false, - "columns": [ - "slug" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.passkeys": { - "name": "passkeys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "user_email": { - "name": "user_email", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "credential_id": { - "name": "credential_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "public_key": { - "name": "public_key", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "passkeys_user_email_users_email_fk": { - "name": "passkeys_user_email_users_email_fk", - "tableFrom": "passkeys", - "tableTo": "users", - "columnsFrom": [ - "user_email" - ], - "columnsTo": [ - "email" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.requests": { - "name": "requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "message": { - "name": "message", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "token": { - "name": "token", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "requests_emails": { - "name": "requests_emails", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "requests_created_at": { - "name": "requests_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "requests_token_tokens_id_fk": { - "name": "requests_token_tokens_id_fk", - "tableFrom": "requests", - "tableTo": "tokens", - "columnsFrom": [ - "token" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.sessions": { - "name": "sessions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "device_name": { - "name": "device_name", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "device_type": { - "name": "device_type", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'desktop'" - }, - "device_os": { - "name": "device_os", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "browser": { - "name": "browser", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "auth_strategy": { - "name": "auth_strategy", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "type": { - "name": "type", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'regular'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "admin_user_id": { - "name": "admin_user_id", - "type": "varchar", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_admin_id": { - "name": "idx_admin_id", - "columns": [ - { - "expression": "admin_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "sessions_user_id_users_id_fk": { - "name": "sessions_user_id_users_id_fk", - "tableFrom": "sessions", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "sessions_admin_user_id_users_id_fk": { - "name": "sessions_admin_user_id_users_id_fk", - "tableFrom": "sessions", - "tableTo": "users", - "columnsFrom": [ - "admin_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tokens": { - "name": "tokens", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "type": { - "name": "type", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "organization_id": { - "name": "organization_id", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "membership_info": { - "name": "membership_info", - "type": "json", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "tokens_user_id_users_id_fk": { - "name": "tokens_user_id_users_id_fk", - "tableFrom": "tokens", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "tokens_organization_id_organizations_id_fk": { - "name": "tokens_organization_id_organizations_id_fk", - "tableFrom": "tokens", - "tableTo": "organizations", - "columnsFrom": [ - "organization_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "tokens_created_by_users_id_fk": { - "name": "tokens_created_by_users_id_fk", - "tableFrom": "tokens", - "tableTo": "users", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar", - "primaryKey": true, - "notNull": true - }, - "entity": { - "name": "entity", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "hashed_password": { - "name": "hashed_password", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "slug": { - "name": "slug", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "unsubscribe_token": { - "name": "unsubscribe_token", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "last_name": { - "name": "last_name", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "email_verified": { - "name": "email_verified", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "bio": { - "name": "bio", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "language": { - "name": "language", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'en'" - }, - "banner_url": { - "name": "banner_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "thumbnail_url": { - "name": "thumbnail_url", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "newsletter": { - "name": "newsletter", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "last_started_at": { - "name": "last_started_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "last_sign_in_at": { - "name": "last_sign_in_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "modified_at": { - "name": "modified_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "modified_by": { - "name": "modified_by", - "type": "varchar", - "primaryKey": false, - "notNull": false - }, - "role": { - "name": "role", - "type": "varchar", - "primaryKey": false, - "notNull": true, - "default": "'user'" - } - }, - "indexes": { - "users_name_index": { - "name": "users_name_index", - "columns": [ - { - "expression": "name", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_token_index": { - "name": "users_token_index", - "columns": [ - { - "expression": "unsubscribe_token", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_email_index": { - "name": "users_email_index", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_created_at_index": { - "name": "users_created_at_index", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "users_modified_by_users_id_fk": { - "name": "users_modified_by_users_id_fk", - "tableFrom": "users", - "tableTo": "users", - "columnsFrom": [ - "modified_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "users_slug_unique": { - "name": "users_slug_unique", - "nullsNotDistinct": false, - "columns": [ - "slug" - ] - }, - "users_unsubscribeToken_unique": { - "name": "users_unsubscribeToken_unique", - "nullsNotDistinct": false, - "columns": [ - "unsubscribe_token" - ] - }, - "users_email_unique": { - "name": "users_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/backend/drizzle/meta/_journal.json b/backend/drizzle/meta/_journal.json index e2d0e8d6e..ba86351bd 100644 --- a/backend/drizzle/meta/_journal.json +++ b/backend/drizzle/meta/_journal.json @@ -5,29 +5,8 @@ { "idx": 0, "version": "7", - "when": 1730984671518, - "tag": "0000_lowly_husk", - "breakpoints": true - }, - { - "idx": 1, - "version": "7", - "when": 1736945246283, - "tag": "0001_gray_the_executioner", - "breakpoints": true - }, - { - "idx": 2, - "version": "7", - "when": 1737372431142, - "tag": "0002_sticky_cassandra_nova", - "breakpoints": true - }, - { - "idx": 3, - "version": "7", - "when": 1737643348061, - "tag": "0003_nasty_jigsaw", + "when": 1737963817654, + "tag": "0000_outstanding_titanium_man", "breakpoints": true } ] diff --git a/backend/emails/README.md b/backend/emails/README.md new file mode 100644 index 000000000..26e458e0d --- /dev/null +++ b/backend/emails/README.md @@ -0,0 +1,6 @@ +# Emails + +Email templates are processed by jsx-email. View backend/package.json for email commands. + + + diff --git a/backend/emails/components/avatar.tsx b/backend/emails/components/avatar.tsx index 2ab9859f0..9bd222b46 100644 --- a/backend/emails/components/avatar.tsx +++ b/backend/emails/components/avatar.tsx @@ -7,6 +7,7 @@ const getRandomColor = () => { return color; }; +// TODO make it use the same color for the same id export const Avatar = ({ name, type = 'user' }: { name?: string | null; type?: 'user' | 'organization' }) => { let initials = 'U'; if (name) { diff --git a/backend/emails/components/user-name.tsx b/backend/emails/components/user-name.tsx deleted file mode 100644 index fbfbb1ae8..000000000 --- a/backend/emails/components/user-name.tsx +++ /dev/null @@ -1,20 +0,0 @@ -export const UserName = ({ beforeText, userName }: { beforeText?: string; userName?: string }) => { - const username = userName || ''; - const contentBeforeText = beforeText || ''; - - return ( -
- dangerouslySetInnerHTML={{ - __html: `${contentBeforeText} ${username}`, - }} - /> - ); -}; - -// Template export -export const Template = UserName; diff --git a/backend/emails/create-password.tsx b/backend/emails/create-password.tsx index 6f90496e0..cf8ffc321 100644 --- a/backend/emails/create-password.tsx +++ b/backend/emails/create-password.tsx @@ -8,7 +8,6 @@ import { EmailContainer } from './components/container'; import { EmailBody } from './components/email-body'; import { EmailButton } from './components/email-button'; import { Footer } from './components/footer'; -import { UserName } from './components/user-name'; import type { BasicTemplateType } from './types'; interface Props extends BasicTemplateType { @@ -16,28 +15,29 @@ interface Props extends BasicTemplateType { } const baseUrl = config.frontendUrl; -const createPasswordUrl = `${baseUrl}/auth/create-password`; +const createPasswordUrl = `${baseUrl}/auth/request-password`; const appName = config.name; -export const CreatePasswordEmail = ({ userName, userLanguage: lng, createPasswordLink = baseUrl }: Props) => { +export const CreatePasswordEmail = ({ userName, userLanguage: lng, createPasswordLink }: Props) => { return ( - {userName && } - -
- dangerouslySetInnerHTML={{ - __html: i18n.t('backend:email.create_password.text', { appName, lng }), - }} - /> + +

{userName && i18n.t('backend:email.hi', { lng, userName })}

+
+ dangerouslySetInnerHTML={{ + __html: i18n.t('backend:email.create_password.text', { appName, lng }), + }} + /> + - + {i18n.t('backend:email.create_password.expire', { lng })} {createPasswordUrl} - {i18n.t('backend:email.create_password.ignore', { lng })} + {i18n.t('backend:email.create_password.ignore', { lng })}