Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: temp profile and accounts tables #1406

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions migrations/schemas/20240710114601-init_temp_accounts_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

-- +migrate Up
CREATE TYPE "public"."profile_type" AS ENUM ('user', 'application', 'vault', 'application_vault');

CREATE TABLE "public"."profiles" (
"id" text NOT NULL PRIMARY KEY,
"created_at" timestamp NOT NULL DEFAULT now(),
"updated_at" timestamp NOT NULL DEFAULT now(),
"profile_name" text,
"avatar" text,
"type" "public"."profile_type" DEFAULT 'user'::profile_type,
"application_id" int4,
"vault_id" int4,
"active_score" int4 NOT NULL DEFAULT 0,
"did_onboarding_telegram" bool NOT NULL DEFAULT false
);

CREATE TABLE "public"."associated_accounts" (
"id" int8 NOT NULL,
"profile_id" text NOT NULL,
"platform" varchar(255) NOT NULL,
"platform_identifier" varchar(255) NOT NULL,
"created_at" timestamp NOT NULL DEFAULT now(),
"updated_at" timestamp NOT NULL DEFAULT now(),
"platform_metadata" json,
CONSTRAINT "fk_profile_id" FOREIGN KEY ("profile_id") REFERENCES "public"."profiles"("id") ON DELETE CASCADE
);

CREATE UNIQUE INDEX aa_platform_platform_identifier_unique ON public.associated_accounts USING btree (platform, platform_identifier);
CREATE INDEX idx_associated_accounts ON public.associated_accounts USING btree (profile_id);
CREATE INDEX idx_associated_accounts_metadata_username ON public.associated_accounts USING gin (to_tsvector('english'::regconfig, (platform_metadata ->> 'username'::text)));
CREATE INDEX idx_onlyy_associated_accounts_profile_id ON public.associated_accounts USING btree (profile_id) INCLUDE (id, platform, platform_identifier, platform_metadata, created_at, updated_at);

-- +migrate Down
DROP TABLE IF EXISTS associated_accounts;
DROP TABLE IF EXISTS profiles;

DROP TYPE IF EXISTS profile_type;
Loading