ps_sheet_qty_run.php 1022 B

12345678910111213141516171819202122
  1. <?php
  2. $root = dirname(dirname(__DIR__));
  3. define('APP_PATH', $root . '/application/');
  4. require $root . '/thinkphp/base.php';
  5. \think\App::initCommon();
  6. function addColumn($table, $column, $ddl)
  7. {
  8. $prefix = \think\Db::getConfig('prefix');
  9. $full = $prefix . $table;
  10. $rows = \think\Db::query('SHOW COLUMNS FROM `' . $full . '` LIKE \'' . addslashes($column) . '\'');
  11. if ($rows) {
  12. echo $full . '.' . $column . " exists\n";
  13. return;
  14. }
  15. \think\Db::execute('ALTER TABLE `' . $full . '` ' . $ddl);
  16. echo $full . '.' . $column . " added\n";
  17. }
  18. addColumn('ps_product', 'qty', "ADD COLUMN `qty` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '总数量' AFTER `unit`");
  19. addColumn('ps_product', 'sheet_qty', "ADD COLUMN `sheet_qty` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '每版数量,一版一张流程单' AFTER `qty`");
  20. addColumn('ps_workorder', 'sheet_qty', "ADD COLUMN `sheet_qty` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '每版数量,一版一张流程单' AFTER `qty`");