0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00
logto/packages/schemas/alterations
2023-01-18 05:12:57 +00:00
..
1.0.0_beta.10-1-logto-config.ts refactor(schemas): fix type path 2022-12-20 13:33:53 +08:00
1.0.0_beta.10-1663923211-machine-to-machine-app.ts refactor(schemas): fix type path 2022-12-20 13:33:53 +08:00
1.0.0_beta.10-1664265197-custom-phrases.ts refactor(schemas): fix type path 2022-12-20 13:33:53 +08:00
1.0.0_beta.11-1664347703-rename-language-key-to-tag.ts refactor(schemas): fix type path 2022-12-20 13:33:53 +08:00
1.0.0_beta.11-1664356000-add-created-at-column-to-users.ts refactor(schemas): fix type path 2022-12-20 13:33:53 +08:00
1.0.0_beta.11-1664462389-correct-user-created-at-column-by-user-logs.ts refactor(schemas): fix type path 2022-12-20 13:33:53 +08:00
1.0.0_beta.14-1665300135-sign-in-sign-up.ts refactor(schemas): fix type path 2022-12-20 13:33:53 +08:00
1.0.0_beta.14-1667283640-remove-forgot-password.ts refactor(schemas): fix type path 2022-12-20 13:33:53 +08:00
1.0.0_beta.14-1667292082-remove-sign-in-method.ts feat(cli): rollback command for alteration (#2975) 2023-01-18 05:12:57 +00:00
1.0.0_beta.14-1667374974-user-suspend.ts refactor(schemas): fix type path 2022-12-20 13:33:53 +08:00
1.0.0_beta.14-1667900481-add-passcode-type-continue.ts feat(cli): rollback command for alteration (#2975) 2023-01-18 05:12:57 +00:00
1.0.0_beta.18-1668666590-support-multiple-connector-instances.ts release: version core packages 2023-01-06 16:48:18 +08:00
1.0.0_beta.18-1668666600-remove-connector-enabled.ts release: version core packages 2023-01-06 16:48:18 +08:00
1.0.0_beta.18-1669091623-roles-and-scopes.ts feat(cli): rollback command for alteration (#2975) 2023-01-18 05:12:57 +00:00
1.0.0_beta.18-1669702299-sign-up.ts release: version core packages 2023-01-06 16:48:18 +08:00
1.0.0_beta.18-1671039448-add-user-name-index.ts release: version core packages 2023-01-06 16:48:18 +08:00
1.0.0_beta.18-1671080370-terms-of-use.ts feat(cli): rollback command for alteration (#2975) 2023-01-18 05:12:57 +00:00
1.0.0_beta.18-1671336831-refactor-log-types.ts release: version core packages 2023-01-06 16:48:18 +08:00
1.0.0_beta.18-1671509870-hooks.ts release: version core packages 2023-01-06 16:48:18 +08:00
1.0.0_beta.18-1672119200-align-passcode-type-with-message-type.ts release: version core packages 2023-01-06 16:48:18 +08:00
next-1672815959-user-roles.ts feat(cli): rollback command for alteration (#2975) 2023-01-18 05:12:57 +00:00
next-1672820345-scope-resource-id.ts feat(cli): rollback command for alteration (#2975) 2023-01-18 05:12:57 +00:00
next-1672901841-roles-and-scopes-not-null.ts feat(cli): rollback command for alteration (#2975) 2023-01-18 05:12:57 +00:00
next-1673001922-support-generic-passcode.ts refactor(schemas): alter passcodes table and set jti to nullable 2023-01-06 22:47:29 +08:00
next-1673165463-scope-name-index.ts feat(core): scope name within the same resource should be unique (#2861) 2023-01-10 05:15:48 +00:00
next-1673349501-sms-sign-in-identifier-to-phone.ts fix(schemas): update sms alteration script (#2949) 2023-01-13 18:08:24 +08:00
next-1673465463-ac-scope-name.ts fix(schemas): modify management api default scope name (#2920) 2023-01-12 08:33:14 +00:00
next-1673853579-ac-default-scope.ts fix(schemas): add alteration for default ac scope (#2953) 2023-01-16 07:45:47 +00:00
next-1673863835-ac-scope-role.ts fix(schemas): fix ac admin id and scope (#2965) 2023-01-17 12:54:14 +08:00
next-1673882867-fix-alteration-issues.ts feat(cli): rollback command for alteration (#2975) 2023-01-18 05:12:57 +00:00
next-1673940577-scope-description-not-null.ts fix(schemas): set scope description to required (#2954) 2023-01-17 18:04:49 +08:00
README.md chore: update contributing (#2209) 2022-10-19 14:47:59 +00:00

Database alteration

The folder for all alteration files.

Format

The alteration files are named in the format of <version>-<timestamp>-name.js where <timestamp> is the unix timestamp of when the alteration was created and name is the name of the alteration, version is this npm package's version number.

As for development, the version is "next" until the package is released.

Note that, you SHOULD NOT change the content of the alteration files after they are created. If you need to change the alteration, you should create a new alteration file with the new content.

Deploy unreleased alterations

To deploy scripts with the next version, run pnpm alteration deploy next. This is helpful if you want to test your alteration scripts.

Typing

type AlterationScript = {
  up: (connection: DatabaseTransactionConnection) => Promise<void>;
  down: (connection: DatabaseTransactionConnection) => Promise<void>;
};

When the alteration script is executed, the up function is called to alter the database schema.

The down function is designed for the future downgrade feature.

Example

export const up = async (connection) => {
  await connection.query(`
    alter table "user"
    add column "email" varchar(255) not null;
  `);
};

export const down = async (connection) => {
  await connection.query(`
    alter table "user"
    drop column "email";
  `);
};