Ejemplo n.º 1
1
 public function columnTypes()
 {
     return [[Schema::TYPE_PK, Schema::primaryKey(), 'integer PRIMARY KEY AUTOINCREMENT NOT NULL'], [Schema::TYPE_PK . '(8)', Schema::primaryKey(8), 'integer PRIMARY KEY AUTOINCREMENT NOT NULL'], [Schema::TYPE_PK . ' CHECK (value > 5)', Schema::primaryKey()->check('value > 5'), 'integer PRIMARY KEY AUTOINCREMENT NOT NULL CHECK (value > 5)'], [Schema::TYPE_PK . '(8) CHECK (value > 5)', Schema::primaryKey(8)->check('value > 5'), 'integer PRIMARY KEY AUTOINCREMENT NOT NULL CHECK (value > 5)'], [Schema::TYPE_STRING, Schema::string(), 'varchar(255)'], [Schema::TYPE_STRING . '(32)', Schema::string(32), 'varchar(32)'], [Schema::TYPE_STRING . ' CHECK (value LIKE "test%")', Schema::string()->check('value LIKE "test%"'), 'varchar(255) CHECK (value LIKE "test%")'], [Schema::TYPE_STRING . '(32) CHECK (value LIKE "test%")', Schema::string(32)->check('value LIKE "test%"'), 'varchar(32) CHECK (value LIKE "test%")'], [Schema::TYPE_STRING . ' NOT NULL', Schema::string()->notNull(), 'varchar(255) NOT NULL'], [Schema::TYPE_TEXT, Schema::text(), 'text'], [Schema::TYPE_TEXT . '(255)', Schema::text(255), 'text'], [Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")', Schema::text()->check('value LIKE "test%"'), 'text CHECK (value LIKE "test%")'], [Schema::TYPE_TEXT . '(255) CHECK (value LIKE "test%")', Schema::text(255)->check('value LIKE "test%"'), 'text CHECK (value LIKE "test%")'], [Schema::TYPE_TEXT . ' NOT NULL', Schema::text()->notNull(), 'text NOT NULL'], [Schema::TYPE_TEXT . '(255) NOT NULL', Schema::text(255)->notNull(), 'text NOT NULL'], [Schema::TYPE_SMALLINT, Schema::smallInteger(), 'smallint'], [Schema::TYPE_SMALLINT . '(8)', Schema::smallInteger(8), 'smallint'], [Schema::TYPE_INTEGER, Schema::integer(), 'integer'], [Schema::TYPE_INTEGER . '(8)', Schema::integer(8), 'integer'], [Schema::TYPE_INTEGER . ' CHECK (value > 5)', Schema::integer()->check('value > 5'), 'integer CHECK (value > 5)'], [Schema::TYPE_INTEGER . '(8) CHECK (value > 5)', Schema::integer(8)->check('value > 5'), 'integer CHECK (value > 5)'], [Schema::TYPE_INTEGER . ' NOT NULL', Schema::integer()->notNull(), 'integer NOT NULL'], [Schema::TYPE_BIGINT, Schema::bigInteger(), 'bigint'], [Schema::TYPE_BIGINT . '(8)', Schema::bigInteger(8), 'bigint'], [Schema::TYPE_BIGINT . ' CHECK (value > 5)', Schema::bigInteger()->check('value > 5'), 'bigint CHECK (value > 5)'], [Schema::TYPE_BIGINT . '(8) CHECK (value > 5)', Schema::bigInteger(8)->check('value > 5'), 'bigint CHECK (value > 5)'], [Schema::TYPE_BIGINT . ' NOT NULL', Schema::bigInteger()->notNull(), 'bigint NOT NULL'], [Schema::TYPE_FLOAT, Schema::float(), 'float'], [Schema::TYPE_FLOAT . '(16,5)', Schema::float(16, 5), 'float'], [Schema::TYPE_FLOAT . ' CHECK (value > 5.6)', Schema::float()->check('value > 5.6'), 'float CHECK (value > 5.6)'], [Schema::TYPE_FLOAT . '(16,5) CHECK (value > 5.6)', Schema::float(16, 5)->check('value > 5.6'), 'float CHECK (value > 5.6)'], [Schema::TYPE_FLOAT . ' NOT NULL', Schema::float()->notNull(), 'float NOT NULL'], [Schema::TYPE_DECIMAL, Schema::decimal(), 'decimal(10,0)'], [Schema::TYPE_DECIMAL . '(12,4)', Schema::decimal(12, 4), 'decimal(12,4)'], [Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)', Schema::decimal()->check('value > 5.6'), 'decimal(10,0) CHECK (value > 5.6)'], [Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)', Schema::decimal(12, 4)->check('value > 5.6'), 'decimal(12,4) CHECK (value > 5.6)'], [Schema::TYPE_DECIMAL . ' NOT NULL', Schema::decimal()->notNull(), 'decimal(10,0) NOT NULL'], [Schema::TYPE_DATETIME, Schema::dateTime(), 'datetime'], [Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", Schema::dateTime()->check("value BETWEEN '2011-01-01' AND '2013-01-01'"), "datetime CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"], [Schema::TYPE_DATETIME . ' NOT NULL', Schema::dateTime()->notNull(), 'datetime NOT NULL'], [Schema::TYPE_TIMESTAMP, Schema::timestamp(), 'timestamp'], [Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", Schema::timestamp()->check("value BETWEEN '2011-01-01' AND '2013-01-01'"), "timestamp CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"], [Schema::TYPE_TIMESTAMP . ' NOT NULL', Schema::timestamp()->notNull(), 'timestamp NOT NULL'], [Schema::TYPE_TIME, Schema::time(), 'time'], [Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')", Schema::time()->check("value BETWEEN '12:00:00' AND '13:01:01'"), "time CHECK (value BETWEEN '12:00:00' AND '13:01:01')"], [Schema::TYPE_TIME . ' NOT NULL', Schema::time()->notNull(), 'time NOT NULL'], [Schema::TYPE_DATE, Schema::date(), 'date'], [Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", Schema::date()->check("value BETWEEN '2011-01-01' AND '2013-01-01'"), "date CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"], [Schema::TYPE_DATE . ' NOT NULL', Schema::date()->notNull(), 'date NOT NULL'], [Schema::TYPE_BINARY, Schema::binary(), 'blob'], [Schema::TYPE_BOOLEAN, Schema::boolean(), 'boolean'], [Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', Schema::boolean()->notNull()->default(1), 'boolean NOT NULL DEFAULT 1'], [Schema::TYPE_MONEY, Schema::money(), 'decimal(19,4)'], [Schema::TYPE_MONEY . '(16,2)', Schema::money(16, 2), 'decimal(16,2)'], [Schema::TYPE_MONEY . ' CHECK (value > 0.0)', Schema::money()->check('value > 0.0'), 'decimal(19,4) CHECK (value > 0.0)'], [Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)', Schema::money(16, 2)->check('value > 0.0'), 'decimal(16,2) CHECK (value > 0.0)'], [Schema::TYPE_MONEY . ' NOT NULL', Schema::money()->notNull(), 'decimal(19,4) NOT NULL']];
 }
 public function up()
 {
     mb_internal_encoding("UTF-8");
     $tableOptions = $this->db->driverName === 'mysql' ? 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB' : null;
     $this->createTable('{{%wysiwyg}}', ['id' => Schema::primaryKey(), 'name' => Schema::string()->notNull(), 'class_name' => Schema::string()->notNull(), 'params' => Schema::text(), 'configuration_model' => Schema::string()], $tableOptions);
     $this->insert('{{%wysiwyg}}', ['name' => 'Imperavi', 'class_name' => 'vova07\\imperavi\\Widget', 'params' => Json::encode(['settings' => ['replaceDivs' => false, 'minHeight' => 200, 'paragraphize' => false, 'pastePlainText' => true, 'buttonSource' => true, 'imageManagerJson' => Url::to(['/backend/dashboard/imperavi-images-get']), 'plugins' => ['table', 'fontsize', 'fontfamily', 'fontcolor', 'video', 'imagemanager'], 'replaceStyles' => [], 'replaceTags' => [], 'deniedTags' => [], 'removeEmpty' => [], 'imageUpload' => Url::to(['/backend/dashboard/imperavi-image-upload'])]]), 'configuration_model' => 'app\\modules\\core\\models\\WysiwygConfiguration\\Imperavi']);
 }
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%widget_menu}}', ['id' => Schema::primaryKey(), 'key' => Schema::string(32)->notNull(), 'title' => Schema::string()->notNull(), 'items' => Schema::text()->notNull(), 'status' => Schema::smallInteger()->notNull()->default(0)], $tableOptions);
 }
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%file_storage_item}}', ['id' => Schema::primaryKey(), 'component' => Schema::string()->notNull(), 'base_url' => Schema::string(1024)->notNull(), 'path' => Schema::string(1024)->notNull(), 'type' => Schema::string(), 'size' => Schema::integer(), 'name' => Schema::string(), 'upload_ip' => Schema::string(15), 'created_at' => Schema::integer()->notNull()], $tableOptions);
 }
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%page}}', ['id' => Schema::primaryKey(), 'slug' => Schema::string(2048)->notNull(), 'title' => Schema::string(512)->notNull(), 'body' => Schema::string()->notNull(), 'view' => Schema::string(), 'status' => Schema::smallInteger()->notNull(), 'created_at' => Schema::integer(), 'updated_at' => Schema::integer()], $tableOptions);
 }
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%widget_text}}', ['id' => Schema::primaryKey(), 'key' => Schema::string()->notNull(), 'title' => Schema::string()->notNull(), 'body' => Schema::text()->notNull(), 'status' => Schema::smallInteger(), 'created_at' => Schema::integer(), 'updated_at' => Schema::integer()], $tableOptions);
     $this->createIndex('idx_widget_text_key', '{{%widget_text}}', 'key');
 }
 public function up()
 {
     $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('{{%user}}', ['id' => Schema::primaryKey(), 'username' => Schema::string()->notNull()->unique(), 'auth_key' => Schema::string(32)->notNull(), 'password_hash' => Schema::string()->notNull(), 'password_reset_token' => Schema::string()->unique(), 'email' => Schema::string()->notNull()->unique(), 'status' => Schema::smallInteger()->notNull()->default(10), 'created_at' => Schema::integer()->notNull(), 'updated_at' => Schema::integer()->notNull()], $tableOptions);
 }
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%user}}', ['id' => Schema::primaryKey(), 'username' => Schema::string(32), 'auth_key' => Schema::string(32)->notNull(), 'password_hash' => Schema::string()->notNull(), 'password_reset_token' => Schema::string(), 'oauth_client' => Schema::string(), 'oauth_client_user_id' => Schema::string(), 'email' => Schema::string()->notNull(), 'status' => Schema::smallInteger()->notNull()->default(User::STATUS_ACTIVE), 'created_at' => Schema::integer(), 'updated_at' => Schema::integer(), 'logged_at' => Schema::integer()], $tableOptions);
     $this->createTable('{{%user_profile}}', ['user_id' => Schema::primaryKey(), 'firstname' => Schema::string(), 'middlename' => Schema::string(), 'lastname' => Schema::string(), 'avatar_path' => Schema::string(), 'avatar_base_url' => Schema::string(), 'locale' => Schema::string(32)->notNull(), 'gender' => Schema::smallInteger(1)], $tableOptions);
     $this->addForeignKey('fk_user', '{{%user_profile}}', 'user_id', '{{%user}}', 'id', 'cascade', 'cascade');
 }
 public function safeUp()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%widget_carousel}}', ['id' => Schema::primaryKey(), 'key' => Schema::string()->notNull(), 'status' => Schema::smallInteger()->default(0)], $tableOptions);
     $this->createTable('{{%widget_carousel_item}}', ['id' => Schema::primaryKey(), 'carousel_id' => Schema::integer()->notNull(), 'base_url' => Schema::string(1024), 'path' => Schema::string(1024), 'type' => Schema::string(), 'url' => Schema::string(1024), 'caption' => Schema::string(1024), 'status' => Schema::smallInteger()->notNull()->default(0), 'order' => Schema::integer()->default(0), 'created_at' => Schema::integer(), 'updated_at' => Schema::integer()], $tableOptions);
     $this->addForeignKey('fk_item_carousel', '{{%widget_carousel_item}}', 'carousel_id', '{{%widget_carousel}}', 'id', 'cascade', 'cascade');
 }
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%timeline_event}}', ['id' => Schema::primaryKey(), 'application' => Schema::string(64)->notNull(), 'category' => Schema::string(64)->notNull(), 'event' => Schema::string(64)->notNull(), 'data' => Schema::text(), 'created_at' => Schema::integer()->notNull()], $tableOptions);
     $this->createIndex('idx_created_at', '{{%timeline_event}}', 'created_at');
     $this->batchInsert('{{%timeline_event}}', ['application', 'category', 'event', 'data', 'created_at'], [['frontend', 'user', 'signup', json_encode(['public_identity' => 'webmaster', 'user_id' => 1, 'created_at' => time()]), time()], ['frontend', 'user', 'signup', json_encode(['public_identity' => 'manager', 'user_id' => 2, 'created_at' => time()]), time()], ['frontend', 'user', 'signup', json_encode(['public_identity' => 'user', 'user_id' => 3, 'created_at' => time()]), time()]]);
 }
 public function up()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%i18n_source_message}}', ['id' => Schema::primaryKey(), 'category' => Schema::string(32), 'message' => Schema::text()], $tableOptions);
     $this->createTable('{{%i18n_message}}', ['id' => Schema::integer(), 'language' => Schema::string(16), 'translation' => Schema::text()], $tableOptions);
     $this->addPrimaryKey('i18n_message_pk', '{{%i18n_message}}', ['id', 'language']);
     $this->addForeignKey('fk_i18n_message_source_message', '{{%i18n_message}}', 'id', '{{%i18n_source_message}}', 'id', 'cascade', 'restrict');
 }
 public function safeUp()
 {
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
     }
     $this->createTable('{{%article_category}}', ['id' => Schema::primaryKey(), 'slug' => Schema::string(1024)->notNull(), 'title' => Schema::string(512)->notNull(), 'body' => Schema::text(), 'parent_id' => Schema::integer(), 'status' => Schema::smallInteger()->notNull()->default(0), 'created_at' => Schema::integer(), 'updated_at' => Schema::integer()], $tableOptions);
     $this->createTable('{{%article}}', ['id' => Schema::primaryKey(), 'slug' => Schema::string(1024)->notNull(), 'title' => Schema::string(512)->notNull(), 'body' => Schema::text()->notNull(), 'view' => Schema::string(), 'category_id' => Schema::integer(), 'thumbnail_base_url' => Schema::string(1024), 'thumbnail_path' => Schema::string(1024), 'author_id' => Schema::integer(), 'updater_id' => Schema::integer(), 'status' => Schema::smallInteger()->notNull()->default(0), 'published_at' => Schema::integer(), 'created_at' => Schema::integer(), 'updated_at' => Schema::integer()], $tableOptions);
     $this->createTable('{{%article_attachment}}', ['id' => Schema::primaryKey(), 'article_id' => Schema::integer()->notNull(), 'path' => Schema::string()->notNull(), 'base_url' => Schema::string(), 'type' => Schema::string(), 'size' => Schema::integer(), 'name' => Schema::string(), 'created_at' => Schema::integer()]);
     $this->addForeignKey('fk_article_attachment_article', '{{%article_attachment}}', 'article_id', '{{%article}}', 'id', 'cascade', 'cascade');
     $this->addForeignKey('fk_article_author', '{{%article}}', 'author_id', '{{%user}}', 'id', 'cascade', 'cascade');
     $this->addForeignKey('fk_article_updater', '{{%article}}', 'updater_id', '{{%user}}', 'id', 'set null', 'cascade');
     $this->addForeignKey('fk_article_category', '{{%article}}', 'category_id', '{{%article_category}}', 'id');
     $this->addForeignKey('fk_article_category_section', '{{%article_category}}', 'parent_id', '{{%article_category}}', 'id', 'cascade', 'cascade');
 }