| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace app\migrations;
- use yii\db\Migration;
- /**
- * Class M230218073419CreateQimallScoreLogRelation
- */
- class M230218073419CreateQimallScoreLogRelation extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- try {
- $table = 'qimall_score_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_score_log_relation` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
- `log_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'score的id/score_frozen的id',
- `source_type` varchar(255) NOT NULL DEFAULT '' COMMENT 'score/score_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 "M230218073419CreateQimallScoreLogRelation cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M230218073419CreateQimallScoreLogRelation cannot be reverted.\n";
- return false;
- }
- */
- }
|