2014-09-25 103 views
2

我在嘗試刪除另一個表(頁面)引用的表(應用程序)時收到此錯誤。如何在PostgreSQL中使用Knex.js進行級聯刪除?

knex.schema.dropTable("application").exec(); 

錯誤是

Possibly unhandled error: cannot drop table application because other objects depend on it 
at Connection.parseE (/home/balan/node_modules/pg/lib/connection.js:526:11) 
at Connection.parseMessage (/home/balan/node_modules/pg/lib/connection.js:356:17) 
at Socket.<anonymous> (/home/balan/node_modules/pg/lib/connection.js:105:22) 
at Socket.EventEmitter.emit (events.js:95:17) 
at Socket.<anonymous> (_stream_readable.js:745:14) 
at Socket.EventEmitter.emit (events.js:92:17) 
at emitReadable_ (_stream_readable.js:407:10) 
at emitReadable (_stream_readable.js:403:5) 
at readableAddChunk (_stream_readable.js:165:9) 
at Socket.Readable.push (_stream_readable.js:127:10) 

回答

6

我只是原始的SQL做到這一點: return knex.raw('DROP TABLE application CASCADE');