使用 sqitch 中的 mysql 查询验证 table 不存在

Verify table does NOT exist with mysql query in sqitch

我正在使用 sqitch 来跟踪数据库更改,它的工作方式之一是使用 sql 查询来验证更改。如果查询 return 出错,则更改被视为不成功。

我有一个更改,我要从我的 mysql 数据库中永久删除 table。要验证部署,如果 table 存在,我的验证需要 return 错误。如果 table 不存在,则 return 错误很简单,但仅当特定 table 存在时,我如何才能使 mysql 到 return 错误存在吗?

使用Sqitch自带的checkit函数,如described in the MySQL tutorial:

SELECT checkit(COUNT(*) = 0, 'Table "foo" exists but should not')
  FROM information_schema.tables
 WHERE table_schema = 'your_db'
   AND table_name = 'dropped_table';