fix: destroy collection fields (#536)
This commit is contained in:
parent
ef939b4277
commit
9dae723ca7
@ -145,6 +145,12 @@ export abstract class Field {
|
||||
let sql;
|
||||
if (this.database.sequelize.getDialect() === 'sqlite') {
|
||||
sql = `SELECT * from pragma_table_info('${this.collection.model.tableName}') WHERE name = '${this.name}'`;
|
||||
} else if (this.database.inDialect('mysql')) {
|
||||
sql = `
|
||||
select column_name
|
||||
from INFORMATION_SCHEMA.COLUMNS
|
||||
where TABLE_SCHEMA='${this.database.options.database}' AND TABLE_NAME='${this.collection.model.tableName}' AND column_name='${this.name}'
|
||||
`;
|
||||
} else {
|
||||
sql = `
|
||||
select column_name
|
||||
|
@ -77,11 +77,11 @@ export class CollectionManagerPlugin extends Plugin {
|
||||
}
|
||||
});
|
||||
|
||||
this.app.db.on('fields.afterDestroy', async (model, options) => {
|
||||
this.app.db.on('fields.beforeDestroy', async (model, options) => {
|
||||
await model.remove(options);
|
||||
});
|
||||
|
||||
this.app.db.on('collections.afterDestroy', async (model, options) => {
|
||||
this.app.db.on('collections.beforeDestroy', async (model, options) => {
|
||||
await model.remove(options);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user