| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace app\migrations;
- use yii\db\Migration;
- /**
- * Class M230218073427CreateQimallBalanceLogRelation
- */
- class M230218073427CreateQimallBalanceLogRelation extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- try {
- $table = 'qimall_balance_log_relation';
- $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
- $res = $this->db->createCommand($sql)->execute();
- if(!empty($res)) return '';
- $sql="
- CREATE TABLE `qimall_balance_log_relation` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
- `log_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'balance的id/balance_frozen的id',
- `source_type` varchar(255) NOT NULL DEFAULT '' COMMENT 'balance/balance_frozen',
- `describe` varchar(1000) NOT NULL DEFAULT '' COMMENT '自定义的描述',
- `created_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间戳',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_source_type_log_id` (`source_type`,`log_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='余额记录关联表表';
- ";
- $this->execute($sql);
- } catch (\Exception $e) {
- }
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M230218073427CreateQimallBalanceLogRelation cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M230218073427CreateQimallBalanceLogRelation cannot be reverted.\n";
- return false;
- }
- */
- }
|