| 123456789101112131415161718192021222324 |
- import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
- const addRoleAndValidUntilToUsers: MigrationLiveDefinition = {
- name: "add_role_and_valid_until_to_users",
- up: async (api) => {
- await api.schema.alterTable('users', (table) => {
- // 用户角色: teacher(教师)/admin(管理员)/student(学生)/fan(粉丝)
- table.enum('role', ['teacher', 'admin', 'student', 'fan'])
- .notNullable()
- .defaultTo('student');
-
- // 账户有效期,为空表示永久有效
- table.timestamp('valid_until').nullable();
- });
- },
- down: async (api) => {
- await api.schema.alterTable('users', (table) => {
- table.dropColumn('role');
- table.dropColumn('valid_until');
- });
- }
- }
- export default addRoleAndValidUntilToUsers;
|