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
2022-12-20 00:02:35 +08:00
..
1.0.0_beta.10-1-logto-config.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
1.0.0_beta.10-1663923211-machine-to-machine-app.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
1.0.0_beta.10-1664265197-custom-phrases.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
1.0.0_beta.11-1664347703-rename-language-key-to-tag.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
1.0.0_beta.11-1664356000-add-created-at-column-to-users.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
1.0.0_beta.11-1664462389-correct-user-created-at-column-by-user-logs.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
1.0.0_beta.14-1665300135-sign-in-sign-up.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
1.0.0_beta.14-1667283640-remove-forgot-password.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
1.0.0_beta.14-1667292082-remove-sign-in-method.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
1.0.0_beta.14-1667374974-user-suspend.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
1.0.0_beta.14-1667900481-add-passcode-type-continue.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
next-1668666590-support-multiple-connector-instances.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
next-1668666600-remove-connector-enabled.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
next-1669091623-roles-and-scopes.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
next-1669702299-sign-up.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
next-1671039448-add-user-name-index.ts refactor: schema export and id generator 2022-12-20 00:02:35 +08:00
next-1671080370-terms-of-use.ts refactor: schema export and id generator 2022-12-20 00:02:35 +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";
  `);
};