Skip to content

Commit

Permalink
Merge pull request #782 from supertokens/schema-update
Browse files Browse the repository at this point in the history
Schema update for 9.0
  • Loading branch information
rishabhpoddar authored Mar 19, 2024
2 parents a8e6055 + 34f13d5 commit 47563f5
Show file tree
Hide file tree
Showing 24 changed files with 576 additions and 108 deletions.
31 changes: 23 additions & 8 deletions v2/community/database-setup/mysql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ CREATE TABLE `tenant_thirdparty_provider_clients` (
FOREIGN KEY (`connection_uri_domain`, `app_id`, `tenant_id`, `third_party_id`) REFERENCES `tenant_thirdparty_providers` (`connection_uri_domain`, `app_id`, `tenant_id`, `third_party_id`) ON DELETE CASCADE
);

CREATE TABLE `tenant_first_factors` (
connection_uri_domain VARCHAR(256) DEFAULT '',
app_id VARCHAR(64) DEFAULT 'public',
tenant_id VARCHAR(64) DEFAULT 'public',
factor_id VARCHAR(128),
PRIMARY KEY (`connection_uri_domain`, `app_id`, `tenant_id`, `factor_id`),
FOREIGN KEY (`connection_uri_domain`, `app_id`, `tenant_id`) REFERENCES `tenant_configs` (`connection_uri_domain`, `app_id`, `tenant_id`) ON DELETE CASCADE
);

CREATE TABLE `tenant_required_secondary_factors` (
connection_uri_domain VARCHAR(256) DEFAULT '',
app_id VARCHAR(64) DEFAULT 'public',
tenant_id VARCHAR(64) DEFAULT 'public',
factor_id VARCHAR(128),
PRIMARY KEY (`connection_uri_domain`, `app_id`, `tenant_id`, `factor_id`),
FOREIGN KEY (`connection_uri_domain`, `app_id`, `tenant_id`) REFERENCES `tenant_configs` (`connection_uri_domain`, `app_id`, `tenant_id`) ON DELETE CASCADE
);

CREATE TABLE `key_value` (
`app_id` varchar(64) NOT NULL DEFAULT 'public',
`tenant_id` varchar(64) NOT NULL DEFAULT 'public',
Expand All @@ -182,6 +200,10 @@ CREATE TABLE `app_id_to_user_id` (
FOREIGN KEY (`app_id`, `primary_or_recipe_user_id`) REFERENCES `app_id_to_user_id` (`app_id`, `user_id`) ON DELETE CASCADE
);

CREATE INDEX app_id_to_user_id_primary_user_id_index ON `app_id_to_user_id` (`primary_or_recipe_user_id`);

CREATE INDEX app_id_to_user_id_user_id_index ON `app_id_to_user_id` (`user_id`);

CREATE TABLE `all_auth_recipe_users` (
`app_id` varchar(64) NOT NULL DEFAULT 'public',
`tenant_id` varchar(64) NOT NULL DEFAULT 'public',
Expand All @@ -201,15 +223,9 @@ CREATE TABLE `all_auth_recipe_users` (
CREATE INDEX all_auth_recipe_users_pagination_index1 ON all_auth_recipe_users
(app_id, tenant_id, primary_or_recipe_user_time_joined DESC, primary_or_recipe_user_id DESC);

CREATE INDEX all_auth_recipe_users_pagination_index2 ON all_auth_recipe_users
(app_id, tenant_id, primary_or_recipe_user_time_joined ASC, primary_or_recipe_user_id DESC);

CREATE INDEX all_auth_recipe_users_pagination_index3 ON all_auth_recipe_users
(recipe_id, app_id, tenant_id, primary_or_recipe_user_time_joined DESC, primary_or_recipe_user_id DESC);

CREATE INDEX all_auth_recipe_users_pagination_index4 ON all_auth_recipe_users
(recipe_id, app_id, tenant_id, primary_or_recipe_user_time_joined ASC, primary_or_recipe_user_id DESC);

CREATE INDEX all_auth_recipe_users_primary_user_id_index ON all_auth_recipe_users
(primary_or_recipe_user_id, app_id);

Expand Down Expand Up @@ -459,8 +475,6 @@ CREATE TABLE `user_roles` (
`user_id` varchar(128) NOT NULL,
`role` varchar(255) NOT NULL,
PRIMARY KEY (`app_id`,`tenant_id`,`user_id`,`role`),
KEY `app_id` (`app_id`,`role`),
FOREIGN KEY (`app_id`, `role`) REFERENCES `roles` (`app_id`, `role`) ON DELETE CASCADE,
FOREIGN KEY (`app_id`, `tenant_id`) REFERENCES `tenants` (`app_id`, `tenant_id`) ON DELETE CASCADE
);

Expand All @@ -481,6 +495,7 @@ CREATE TABLE `totp_user_devices` (
`period` int NOT NULL,
`skew` int NOT NULL,
`verified` tinyint(1) NOT NULL,
`created_at` BIGINT UNSIGNED,
PRIMARY KEY (`app_id`,`user_id`,`device_name`),
FOREIGN KEY (`app_id`, `user_id`) REFERENCES `totp_users` (`app_id`, `user_id`) ON DELETE CASCADE
);
Expand Down
26 changes: 25 additions & 1 deletion v2/community/database-setup/postgresql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,28 @@ CREATE TABLE tenant_thirdparty_provider_clients (
CREATE INDEX tenant_thirdparty_provider_clients_third_party_id_index ON tenant_thirdparty_provider_clients (connection_uri_domain, app_id, tenant_id, third_party_id);
CREATE TABLE tenant_first_factors (
connection_uri_domain VARCHAR(256) DEFAULT '' NOT NULL,
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
factor_id VARCHAR(128),
CONSTRAINT tenant_first_factors_pkey PRIMARY KEY (connection_uri_domain, app_id, tenant_id, factor_id),
CONSTRAINT tenant_first_factors_tenant_id_fkey FOREIGN KEY (connection_uri_domain, app_id, tenant_id) REFERENCES public.tenant_configs(connection_uri_domain, app_id, tenant_id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS tenant_first_factors_tenant_id_index ON tenant_first_factors (connection_uri_domain, app_id, tenant_id);
CREATE TABLE tenant_required_secondary_factors (
connection_uri_domain VARCHAR(256) DEFAULT '' NOT NULL,
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
factor_id VARCHAR(128),
CONSTRAINT tenant_required_secondary_factors_pkey PRIMARY KEY (connection_uri_domain, app_id, tenant_id, factor_id),
CONSTRAINT tenant_required_secondary_factors_tenant_id_fkey FOREIGN KEY (connection_uri_domain, app_id, tenant_id) REFERENCES public.tenant_configs(connection_uri_domain, app_id, tenant_id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS tenant_default_required_factor_ids_tenant_id_index ON tenant_required_secondary_factors (connection_uri_domain, app_id, tenant_id);
CREATE TABLE key_value (
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
Expand All @@ -197,6 +219,8 @@ CREATE TABLE app_id_to_user_id (
CREATE INDEX app_id_to_user_id_app_id_index ON app_id_to_user_id (app_id);
CREATE INDEX app_id_to_user_id_primary_user_id_index ON app_id_to_user_id (primary_or_recipe_user_id, app_id);
CREATE TABLE all_auth_recipe_users (
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
Expand Down Expand Up @@ -507,7 +531,6 @@ CREATE TABLE user_roles (
user_id VARCHAR(128) NOT NULL,
role VARCHAR(255) NOT NULL,
CONSTRAINT user_roles_pkey PRIMARY KEY (app_id, tenant_id, user_id, role),
CONSTRAINT user_roles_role_fkey FOREIGN KEY (app_id, role) REFERENCES public.roles(app_id, role) ON DELETE CASCADE,
CONSTRAINT user_roles_tenant_id_fkey FOREIGN KEY (app_id, tenant_id) REFERENCES public.tenants(app_id, tenant_id) ON DELETE CASCADE
);
Expand All @@ -534,6 +557,7 @@ CREATE TABLE totp_user_devices (
period integer NOT NULL,
skew integer NOT NULL,
verified BOOLEAN NOT NULL,
created_at BIGINT,
CONSTRAINT totp_user_devices_pkey PRIMARY KEY (app_id, user_id, device_name),
CONSTRAINT totp_user_devices_user_id_fkey FOREIGN KEY (app_id, user_id) REFERENCES public.totp_users(app_id, user_id) ON DELETE CASCADE
);
Expand Down
31 changes: 23 additions & 8 deletions v2/emailpassword/custom-ui/init/database-setup/mysql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ CREATE TABLE `tenant_thirdparty_provider_clients` (
FOREIGN KEY (`connection_uri_domain`, `app_id`, `tenant_id`, `third_party_id`) REFERENCES `tenant_thirdparty_providers` (`connection_uri_domain`, `app_id`, `tenant_id`, `third_party_id`) ON DELETE CASCADE
);

CREATE TABLE `tenant_first_factors` (
connection_uri_domain VARCHAR(256) DEFAULT '',
app_id VARCHAR(64) DEFAULT 'public',
tenant_id VARCHAR(64) DEFAULT 'public',
factor_id VARCHAR(128),
PRIMARY KEY (`connection_uri_domain`, `app_id`, `tenant_id`, `factor_id`),
FOREIGN KEY (`connection_uri_domain`, `app_id`, `tenant_id`) REFERENCES `tenant_configs` (`connection_uri_domain`, `app_id`, `tenant_id`) ON DELETE CASCADE
);

CREATE TABLE `tenant_required_secondary_factors` (
connection_uri_domain VARCHAR(256) DEFAULT '',
app_id VARCHAR(64) DEFAULT 'public',
tenant_id VARCHAR(64) DEFAULT 'public',
factor_id VARCHAR(128),
PRIMARY KEY (`connection_uri_domain`, `app_id`, `tenant_id`, `factor_id`),
FOREIGN KEY (`connection_uri_domain`, `app_id`, `tenant_id`) REFERENCES `tenant_configs` (`connection_uri_domain`, `app_id`, `tenant_id`) ON DELETE CASCADE
);

CREATE TABLE `key_value` (
`app_id` varchar(64) NOT NULL DEFAULT 'public',
`tenant_id` varchar(64) NOT NULL DEFAULT 'public',
Expand All @@ -182,6 +200,10 @@ CREATE TABLE `app_id_to_user_id` (
FOREIGN KEY (`app_id`, `primary_or_recipe_user_id`) REFERENCES `app_id_to_user_id` (`app_id`, `user_id`) ON DELETE CASCADE
);

CREATE INDEX app_id_to_user_id_primary_user_id_index ON `app_id_to_user_id` (`primary_or_recipe_user_id`);

CREATE INDEX app_id_to_user_id_user_id_index ON `app_id_to_user_id` (`user_id`);

CREATE TABLE `all_auth_recipe_users` (
`app_id` varchar(64) NOT NULL DEFAULT 'public',
`tenant_id` varchar(64) NOT NULL DEFAULT 'public',
Expand All @@ -201,15 +223,9 @@ CREATE TABLE `all_auth_recipe_users` (
CREATE INDEX all_auth_recipe_users_pagination_index1 ON all_auth_recipe_users
(app_id, tenant_id, primary_or_recipe_user_time_joined DESC, primary_or_recipe_user_id DESC);

CREATE INDEX all_auth_recipe_users_pagination_index2 ON all_auth_recipe_users
(app_id, tenant_id, primary_or_recipe_user_time_joined ASC, primary_or_recipe_user_id DESC);

CREATE INDEX all_auth_recipe_users_pagination_index3 ON all_auth_recipe_users
(recipe_id, app_id, tenant_id, primary_or_recipe_user_time_joined DESC, primary_or_recipe_user_id DESC);

CREATE INDEX all_auth_recipe_users_pagination_index4 ON all_auth_recipe_users
(recipe_id, app_id, tenant_id, primary_or_recipe_user_time_joined ASC, primary_or_recipe_user_id DESC);

CREATE INDEX all_auth_recipe_users_primary_user_id_index ON all_auth_recipe_users
(primary_or_recipe_user_id, app_id);

Expand Down Expand Up @@ -459,8 +475,6 @@ CREATE TABLE `user_roles` (
`user_id` varchar(128) NOT NULL,
`role` varchar(255) NOT NULL,
PRIMARY KEY (`app_id`,`tenant_id`,`user_id`,`role`),
KEY `app_id` (`app_id`,`role`),
FOREIGN KEY (`app_id`, `role`) REFERENCES `roles` (`app_id`, `role`) ON DELETE CASCADE,
FOREIGN KEY (`app_id`, `tenant_id`) REFERENCES `tenants` (`app_id`, `tenant_id`) ON DELETE CASCADE
);

Expand All @@ -481,6 +495,7 @@ CREATE TABLE `totp_user_devices` (
`period` int NOT NULL,
`skew` int NOT NULL,
`verified` tinyint(1) NOT NULL,
`created_at` BIGINT UNSIGNED,
PRIMARY KEY (`app_id`,`user_id`,`device_name`),
FOREIGN KEY (`app_id`, `user_id`) REFERENCES `totp_users` (`app_id`, `user_id`) ON DELETE CASCADE
);
Expand Down
26 changes: 25 additions & 1 deletion v2/emailpassword/custom-ui/init/database-setup/postgresql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,28 @@ CREATE TABLE tenant_thirdparty_provider_clients (
CREATE INDEX tenant_thirdparty_provider_clients_third_party_id_index ON tenant_thirdparty_provider_clients (connection_uri_domain, app_id, tenant_id, third_party_id);
CREATE TABLE tenant_first_factors (
connection_uri_domain VARCHAR(256) DEFAULT '' NOT NULL,
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
factor_id VARCHAR(128),
CONSTRAINT tenant_first_factors_pkey PRIMARY KEY (connection_uri_domain, app_id, tenant_id, factor_id),
CONSTRAINT tenant_first_factors_tenant_id_fkey FOREIGN KEY (connection_uri_domain, app_id, tenant_id) REFERENCES public.tenant_configs(connection_uri_domain, app_id, tenant_id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS tenant_first_factors_tenant_id_index ON tenant_first_factors (connection_uri_domain, app_id, tenant_id);
CREATE TABLE tenant_required_secondary_factors (
connection_uri_domain VARCHAR(256) DEFAULT '' NOT NULL,
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
factor_id VARCHAR(128),
CONSTRAINT tenant_required_secondary_factors_pkey PRIMARY KEY (connection_uri_domain, app_id, tenant_id, factor_id),
CONSTRAINT tenant_required_secondary_factors_tenant_id_fkey FOREIGN KEY (connection_uri_domain, app_id, tenant_id) REFERENCES public.tenant_configs(connection_uri_domain, app_id, tenant_id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS tenant_default_required_factor_ids_tenant_id_index ON tenant_required_secondary_factors (connection_uri_domain, app_id, tenant_id);
CREATE TABLE key_value (
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
Expand All @@ -197,6 +219,8 @@ CREATE TABLE app_id_to_user_id (
CREATE INDEX app_id_to_user_id_app_id_index ON app_id_to_user_id (app_id);
CREATE INDEX app_id_to_user_id_primary_user_id_index ON app_id_to_user_id (primary_or_recipe_user_id, app_id);
CREATE TABLE all_auth_recipe_users (
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
Expand Down Expand Up @@ -507,7 +531,6 @@ CREATE TABLE user_roles (
user_id VARCHAR(128) NOT NULL,
role VARCHAR(255) NOT NULL,
CONSTRAINT user_roles_pkey PRIMARY KEY (app_id, tenant_id, user_id, role),
CONSTRAINT user_roles_role_fkey FOREIGN KEY (app_id, role) REFERENCES public.roles(app_id, role) ON DELETE CASCADE,
CONSTRAINT user_roles_tenant_id_fkey FOREIGN KEY (app_id, tenant_id) REFERENCES public.tenants(app_id, tenant_id) ON DELETE CASCADE
);
Expand All @@ -534,6 +557,7 @@ CREATE TABLE totp_user_devices (
period integer NOT NULL,
skew integer NOT NULL,
verified BOOLEAN NOT NULL,
created_at BIGINT,
CONSTRAINT totp_user_devices_pkey PRIMARY KEY (app_id, user_id, device_name),
CONSTRAINT totp_user_devices_user_id_fkey FOREIGN KEY (app_id, user_id) REFERENCES public.totp_users(app_id, user_id) ON DELETE CASCADE
);
Expand Down
31 changes: 23 additions & 8 deletions v2/emailpassword/pre-built-ui/setup/database-setup/mysql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ CREATE TABLE `tenant_thirdparty_provider_clients` (
FOREIGN KEY (`connection_uri_domain`, `app_id`, `tenant_id`, `third_party_id`) REFERENCES `tenant_thirdparty_providers` (`connection_uri_domain`, `app_id`, `tenant_id`, `third_party_id`) ON DELETE CASCADE
);

CREATE TABLE `tenant_first_factors` (
connection_uri_domain VARCHAR(256) DEFAULT '',
app_id VARCHAR(64) DEFAULT 'public',
tenant_id VARCHAR(64) DEFAULT 'public',
factor_id VARCHAR(128),
PRIMARY KEY (`connection_uri_domain`, `app_id`, `tenant_id`, `factor_id`),
FOREIGN KEY (`connection_uri_domain`, `app_id`, `tenant_id`) REFERENCES `tenant_configs` (`connection_uri_domain`, `app_id`, `tenant_id`) ON DELETE CASCADE
);

CREATE TABLE `tenant_required_secondary_factors` (
connection_uri_domain VARCHAR(256) DEFAULT '',
app_id VARCHAR(64) DEFAULT 'public',
tenant_id VARCHAR(64) DEFAULT 'public',
factor_id VARCHAR(128),
PRIMARY KEY (`connection_uri_domain`, `app_id`, `tenant_id`, `factor_id`),
FOREIGN KEY (`connection_uri_domain`, `app_id`, `tenant_id`) REFERENCES `tenant_configs` (`connection_uri_domain`, `app_id`, `tenant_id`) ON DELETE CASCADE
);

CREATE TABLE `key_value` (
`app_id` varchar(64) NOT NULL DEFAULT 'public',
`tenant_id` varchar(64) NOT NULL DEFAULT 'public',
Expand All @@ -182,6 +200,10 @@ CREATE TABLE `app_id_to_user_id` (
FOREIGN KEY (`app_id`, `primary_or_recipe_user_id`) REFERENCES `app_id_to_user_id` (`app_id`, `user_id`) ON DELETE CASCADE
);

CREATE INDEX app_id_to_user_id_primary_user_id_index ON `app_id_to_user_id` (`primary_or_recipe_user_id`);

CREATE INDEX app_id_to_user_id_user_id_index ON `app_id_to_user_id` (`user_id`);

CREATE TABLE `all_auth_recipe_users` (
`app_id` varchar(64) NOT NULL DEFAULT 'public',
`tenant_id` varchar(64) NOT NULL DEFAULT 'public',
Expand All @@ -201,15 +223,9 @@ CREATE TABLE `all_auth_recipe_users` (
CREATE INDEX all_auth_recipe_users_pagination_index1 ON all_auth_recipe_users
(app_id, tenant_id, primary_or_recipe_user_time_joined DESC, primary_or_recipe_user_id DESC);

CREATE INDEX all_auth_recipe_users_pagination_index2 ON all_auth_recipe_users
(app_id, tenant_id, primary_or_recipe_user_time_joined ASC, primary_or_recipe_user_id DESC);

CREATE INDEX all_auth_recipe_users_pagination_index3 ON all_auth_recipe_users
(recipe_id, app_id, tenant_id, primary_or_recipe_user_time_joined DESC, primary_or_recipe_user_id DESC);

CREATE INDEX all_auth_recipe_users_pagination_index4 ON all_auth_recipe_users
(recipe_id, app_id, tenant_id, primary_or_recipe_user_time_joined ASC, primary_or_recipe_user_id DESC);

CREATE INDEX all_auth_recipe_users_primary_user_id_index ON all_auth_recipe_users
(primary_or_recipe_user_id, app_id);

Expand Down Expand Up @@ -459,8 +475,6 @@ CREATE TABLE `user_roles` (
`user_id` varchar(128) NOT NULL,
`role` varchar(255) NOT NULL,
PRIMARY KEY (`app_id`,`tenant_id`,`user_id`,`role`),
KEY `app_id` (`app_id`,`role`),
FOREIGN KEY (`app_id`, `role`) REFERENCES `roles` (`app_id`, `role`) ON DELETE CASCADE,
FOREIGN KEY (`app_id`, `tenant_id`) REFERENCES `tenants` (`app_id`, `tenant_id`) ON DELETE CASCADE
);

Expand All @@ -481,6 +495,7 @@ CREATE TABLE `totp_user_devices` (
`period` int NOT NULL,
`skew` int NOT NULL,
`verified` tinyint(1) NOT NULL,
`created_at` BIGINT UNSIGNED,
PRIMARY KEY (`app_id`,`user_id`,`device_name`),
FOREIGN KEY (`app_id`, `user_id`) REFERENCES `totp_users` (`app_id`, `user_id`) ON DELETE CASCADE
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,28 @@ CREATE TABLE tenant_thirdparty_provider_clients (
CREATE INDEX tenant_thirdparty_provider_clients_third_party_id_index ON tenant_thirdparty_provider_clients (connection_uri_domain, app_id, tenant_id, third_party_id);
CREATE TABLE tenant_first_factors (
connection_uri_domain VARCHAR(256) DEFAULT '' NOT NULL,
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
factor_id VARCHAR(128),
CONSTRAINT tenant_first_factors_pkey PRIMARY KEY (connection_uri_domain, app_id, tenant_id, factor_id),
CONSTRAINT tenant_first_factors_tenant_id_fkey FOREIGN KEY (connection_uri_domain, app_id, tenant_id) REFERENCES public.tenant_configs(connection_uri_domain, app_id, tenant_id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS tenant_first_factors_tenant_id_index ON tenant_first_factors (connection_uri_domain, app_id, tenant_id);
CREATE TABLE tenant_required_secondary_factors (
connection_uri_domain VARCHAR(256) DEFAULT '' NOT NULL,
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
factor_id VARCHAR(128),
CONSTRAINT tenant_required_secondary_factors_pkey PRIMARY KEY (connection_uri_domain, app_id, tenant_id, factor_id),
CONSTRAINT tenant_required_secondary_factors_tenant_id_fkey FOREIGN KEY (connection_uri_domain, app_id, tenant_id) REFERENCES public.tenant_configs(connection_uri_domain, app_id, tenant_id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS tenant_default_required_factor_ids_tenant_id_index ON tenant_required_secondary_factors (connection_uri_domain, app_id, tenant_id);
CREATE TABLE key_value (
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
Expand All @@ -197,6 +219,8 @@ CREATE TABLE app_id_to_user_id (
CREATE INDEX app_id_to_user_id_app_id_index ON app_id_to_user_id (app_id);
CREATE INDEX app_id_to_user_id_primary_user_id_index ON app_id_to_user_id (primary_or_recipe_user_id, app_id);
CREATE TABLE all_auth_recipe_users (
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
Expand Down Expand Up @@ -507,7 +531,6 @@ CREATE TABLE user_roles (
user_id VARCHAR(128) NOT NULL,
role VARCHAR(255) NOT NULL,
CONSTRAINT user_roles_pkey PRIMARY KEY (app_id, tenant_id, user_id, role),
CONSTRAINT user_roles_role_fkey FOREIGN KEY (app_id, role) REFERENCES public.roles(app_id, role) ON DELETE CASCADE,
CONSTRAINT user_roles_tenant_id_fkey FOREIGN KEY (app_id, tenant_id) REFERENCES public.tenants(app_id, tenant_id) ON DELETE CASCADE
);
Expand All @@ -534,6 +557,7 @@ CREATE TABLE totp_user_devices (
period integer NOT NULL,
skew integer NOT NULL,
verified BOOLEAN NOT NULL,
created_at BIGINT,
CONSTRAINT totp_user_devices_pkey PRIMARY KEY (app_id, user_id, device_name),
CONSTRAINT totp_user_devices_user_id_fkey FOREIGN KEY (app_id, user_id) REFERENCES public.totp_users(app_id, user_id) ON DELETE CASCADE
);
Expand Down
Loading

0 comments on commit 47563f5

Please sign in to comment.