()
| 3 | declare let queryInterface: QueryInterface; |
| 4 | |
| 5 | async function test() { |
| 6 | await queryInterface.createTable( |
| 7 | 'nameOfTheNewTable', |
| 8 | { |
| 9 | attr1: DataTypes.STRING, |
| 10 | attr2: DataTypes.INTEGER, |
| 11 | attr3: { |
| 12 | allowNull: false, |
| 13 | defaultValue: false, |
| 14 | type: DataTypes.BOOLEAN, |
| 15 | }, |
| 16 | // foreign key usage |
| 17 | attr4: { |
| 18 | onDelete: 'cascade', |
| 19 | onUpdate: 'cascade', |
| 20 | references: { |
| 21 | key: 'id', |
| 22 | model: 'another_table_name', |
| 23 | }, |
| 24 | type: DataTypes.INTEGER, |
| 25 | }, |
| 26 | attr5: { |
| 27 | onDelete: 'cascade', |
| 28 | onUpdate: 'cascade', |
| 29 | references: { |
| 30 | key: 'id', |
| 31 | model: { schema: '<schema>', tableName: 'another_table_name' }, |
| 32 | }, |
| 33 | type: DataTypes.INTEGER, |
| 34 | }, |
| 35 | createdAt: { |
| 36 | type: DataTypes.DATE, |
| 37 | }, |
| 38 | id: { |
| 39 | autoIncrement: true, |
| 40 | primaryKey: true, |
| 41 | type: DataTypes.INTEGER, |
| 42 | }, |
| 43 | updatedAt: { |
| 44 | type: DataTypes.DATE, |
| 45 | }, |
| 46 | }, |
| 47 | { |
| 48 | charset: 'latin1', // default: null |
| 49 | collate: 'latin1_general_ci', |
| 50 | engine: 'MYISAM', // default: 'InnoDB' |
| 51 | uniqueKeys: { |
| 52 | test: { |
| 53 | customIndex: true, |
| 54 | fields: ['attr2', 'attr3'], |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | ); |
| 59 | await queryInterface.createTable({ tableName: '<table-name>' }, {}); |
| 60 | |
| 61 | await queryInterface.dropTable('nameOfTheExistingTable'); |
| 62 | await queryInterface.dropTable({ schema: '<schema>', tableName: 'nameOfTheExistingTable' }); |
nothing calls this directly
no test coverage detected