Skip to content

Commit

Permalink
fix: migration scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Mar 14, 2024
1 parent 776f79a commit 1953201
Showing 1 changed file with 73 additions and 1 deletion.
74 changes: 73 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,79 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Migration

- TODO - copy once postgres / mysql changelog is done
<details>

<summary>If using PostgreSQL</summary>

```sql
CREATE TABLE IF NOT EXISTS 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),
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 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 IF NOT EXISTS 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),
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 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);

ALTER TABLE totp_user_devices ADD COLUMN IF NOT EXISTS created_at BIGINT default 0;
ALTER TABLE totp_user_devices
ALTER COLUMN created_at DROP DEFAULT;
```

</details>

<details>

<summary>If using MySQL</summary>

```sql
CREATE TABLE IF NOT EXISTS 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 IF NOT EXISTS 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
);

ALTER TABLE totp_user_devices ADD COLUMN created_at BIGINT UNSIGNED default 0;
ALTER TABLE totp_user_devices
ALTER COLUMN created_at DROP DEFAULT;
```

</details>

## [8.0.1] - 2024-03-11

Expand Down

0 comments on commit 1953201

Please sign in to comment.