add property and property definition

This commit is contained in:
Roland Schneider
2021-10-11 22:32:43 +02:00
parent a2c828cc19
commit e6d4d0ffc4
13 changed files with 604 additions and 1 deletions

View File

@@ -0,0 +1,67 @@
<?php
use yii\db\Migration;
/**
* Class m211011_050352_add_properties
*/
class m211011_050352_add_properties extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%property_definition}}', [
'id' => $this->primaryKey(),
'name' => $this->string(100)->notNull(),
'label' => $this->string(100)->notNull(),
'type' => $this->string(100)->notNull(),
'config' => $this->string(),
'created_at' => $this->timestamp()->notNull(),
'updated_at' => $this->timestamp()->notNull(),
], $tableOptions);
$this->createTable('{{%property}}', [
'id' => $this->primaryKey(),
'id_user' => $this->integer(11),
'id_property_definition' => $this->integer(11),
'value' => $this->string(),
'created_at' => $this->timestamp()->notNull(),
'updated_at' => $this->timestamp()->notNull(),
], $tableOptions);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
echo "m211011_050352_add_properties cannot be reverted.\n";
return false;
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m211011_050352_add_properties cannot be reverted.\n";
return false;
}
*/
}

View File

@@ -0,0 +1,57 @@
<?php
use yii\db\Migration;
/**
* Class m211011_052008_add_property_group_training_customer_cancel_interval
*/
class m211011_052008_add_property_group_training_customer_cancel_interval extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->insert("property_definition",
[
'name' => 'GROUP_TRAINING_CUSTOMER_CANCEL_TIME_LIMIT',
'label' => 'Csoportos edzés - lemondás idő korlát (perc):',
'type' => 'integer'
]);
$insertId = Yii::$app->db->getLastInsertID();
$user = \common\models\User::find()->andWhere(['username' => 'admin'])->one();
$this->insert("property",[
'id_user' => $user->id,
'id_property_definition' => $insertId,
'value' => '60'
]);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
echo "m211011_052008_add_property_group_training_customer_cancel_interval cannot be reverted.\n";
return false;
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m211011_052008_add_property_group_training_customer_cancel_interval cannot be reverted.\n";
return false;
}
*/
}