芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/xmintal-back/migrations/m240530_050342_create_base_tables.php
createTable( '{{%profile}}', [ 'id' => 'pk', 'name' => $this->string(200), 'permissions' => $this->text(), 'sort_order' => $this->integer(), 'created' => $this->timestamp(), 'updated' => $this->timestamp(), 'trash' => $this->tinyInteger(1), 'active' => $this->tinyInteger(1) ] ); //Table user (usuario) $this->createTable( '{{%user}}', [ 'id' => 'pk', 'profile_id'=>$this->integer(), 'name' => $this->string(200), 'email' => $this->string(255), 'mobile' => $this->string(200), 'username' => $this->string(50), 'password'=>$this->string(200), 'access_token'=>$this->string(200), 'refresh_token'=>$this->string(200), 'recover_token'=>$this->string(200), 'profile_changes'=>$this->tinyInteger(1), 'sort_order' => $this->integer(), 'created' => $this->timestamp(), 'updated' => $this->timestamp(), 'trash' => $this->tinyInteger(1), 'active' => $this->tinyInteger(1) ] ); //Table customer (cliente) $this->createTable( '{{%customer}}', [ 'id' => 'pk', 'name' => $this->string(200), 'username'=>$this->string(25), 'password'=>$this->string(150), 'email' => $this->string(150), 'mobile' => $this->string(20), 'locale' => $this->string(50), 'street' => $this->string(50), 'number' => $this->string(10), 'intersection' => $this->string(50), 'sort_order' => $this->integer(), 'created' => $this->timestamp(), 'updated' => $this->timestamp(), 'trash' => $this->tinyInteger(1), 'active' => $this->tinyInteger(1) ] ); //Table license (licencia) $this->createTable( '{{%license}}', [ 'id' => 'pk', 'name'=>$this->string(150), 'price'=>$this->string(10), 'month_duration'=>$this->integer(2), 'sort_order' => $this->integer(), 'created' => $this->timestamp(), 'updated' => $this->timestamp(), 'trash' => $this->tinyInteger(1), 'active' => $this->tinyInteger(1) ] ); //Table customer_license (tabla de unión usuario y licencia) $this->createTable( '{{%customer_license}}', [ 'id' => 'pk', 'license_id'=>$this->integer(), 'customer_id'=>$this->integer(), 'price' => $this->string(10), 'month_duration'=>$this->integer(2), 'mac_address' => $this->string(80), 'license_key'=>$this->string(80), 'device_name'=>$this->string(150), ] ); //Table payment (payment) $this->createTable( '{{%payment}}', [ 'id' => 'pk', 'payment_type'=>$this->string(10), 'amount' => $this->string(10), 'concept'=>$this->string(200), 'customerlicense_id'=>$this->integer(), 'payment_date' => $this->timestamp(), 'payment_method' => $this->string(15), 'payment_reference' => $this->string(100), 'validity_start_date'=>$this->timestamp(), 'validity_end_date'=>$this->timestamp(), 'sort_order' => $this->integer(), 'created' => $this->timestamp(), 'updated' => $this->timestamp(), 'trash' => $this->tinyInteger(1), 'active' => $this->tinyInteger(1) ] ); $this->createIndex('user_profile_idx','{{%user}}','profile_id'); $this->addForeignKey('user_profile_fk','{{%user}}','profile_id','{{%profile}}','id','NO ACTION','NO ACTION'); $this->createIndex('customerlicense_customer_idx','{{%customer_license}}','customer_id'); $this->addForeignKey('customerlicense_customer_fk','{{%customer_license}}','customer_id','{{%customer}}','id','CASCADE','CASCADE'); $this->createIndex('customerlicense_license_idx','{{%customer_license}}','license_id'); $this->addForeignKey('customerlicense_license_fk','{{%customer_license}}','license_id','{{%license}}','id','CASCADE','CASCADE'); $this->createIndex('payment_customerlicense_idx','{{%payment}}','customerlicense_id'); $this->addForeignKey('payment_customerlicense_fk','{{%payment}}','customerlicense_id','{{%customer_license}}','id','CASCADE','CASCADE'); $this->insert('{{%profile}}',['name'=>'Administrador','permissions'=>$this->encodePermissions(),'trash'=>0,'active'=>1]); $this->insert('{{%user}}',['profile_id'=>1,'mobile'=>'--','name'=>'Administrador','username'=>'admin','email'=>'admin@xmintal.com','password'=>Yii::$app->security->generatePasswordHash('2420¡4dm1n'),'active'=>1,'trash'=>0]); } private function encodePermissions(){ $permissions=[]; $system_permissions=Yii::$app->params['permissions']; foreach($system_permissions as $permission){ $permissions[]=['controller'=>$permission['controller'],'actions'=>array_keys($permission['actions'])]; } $encoded_permissions=Json::encode($permissions); return $encoded_permissions; } /** * {@inheritdoc} */ public function safeDown() { return false; } /* // Use up()/down() to run migration code without a transaction. public function up() { } public function down() { echo "m240530_050342_create_base_tables cannot be reverted.\n"; return false; } */ }