/** * Migrate Up. */ public function up() { $this->createTable(LunaTable::CATEGORIES, function (Schema $schema) { $schema->primary('id')->comment('Primary Key'); $schema->integer('parent_id')->comment('Parent ID'); $schema->integer('lft')->comment('Left Key'); $schema->integer('rgt')->signed(true)->comment('Right key'); $schema->integer('level')->signed(true)->comment('Nested Level'); $schema->varchar('path')->comment('Alias Path'); $schema->varchar('type')->length(50)->comment('Content Type'); $schema->varchar('title')->comment('Title'); $schema->varchar('alias')->comment('Alias'); $schema->varchar('image')->comment('Main Image'); $schema->text('description')->comment('Description Text'); $schema->tinyint('state')->signed(true)->comment('0: unpublished, 1:published'); $schema->datetime('created')->comment('Created Date'); $schema->integer('created_by')->comment('Author'); $schema->datetime('modified')->comment('Modified Date'); $schema->integer('modified_by')->comment('Modified User'); $schema->char('language')->length(7)->comment('Language'); $schema->text('params')->comment('Params'); $schema->addIndex('alias'); $schema->addIndex('path'); $schema->addIndex(['lft', 'rgt']); $schema->addIndex('language'); $schema->addIndex('created_by'); }); $record = new CategoryRecord(); $record->createRoot(); }
/** * doClear * * @return void */ public function doClear() { $this->truncate(LunaTable::CATEGORIES); $record = new CategoryRecord(); $record->createRoot(); }
/** * Migrate Up. */ public function up() { $this->db->getTable(LunaTable::CATEGORIES, true)->addColumn(new Column\Primary('id'))->addColumn(new Column\Integer('parent_id'))->addColumn(new Column\Integer('level'))->addColumn(new Column\Integer('lft'))->addColumn(new Column\Integer('rgt'))->addColumn(new Column\Varchar('path'))->addColumn(new Column\Varchar('title'))->addColumn(new Column\Varchar('alias'))->addColumn(new Column\Text('description'))->addColumn(new Column\Text('images'))->addColumn(new Column\Integer('version'))->addColumn(new Column\Integer('topics'))->addColumn(new Column\Integer('posts'))->addColumn(new Column\Datetime('created'))->addColumn(new Column\Integer('created_by'))->addColumn(new Column\Datetime('modified'))->addColumn(new Column\Integer('modified_by'))->addColumn(new Column\Tinyint('state'))->addColumn(new Column\Integer('access'))->addColumn(new Column\Text('params'))->addIndex(Key::TYPE_INDEX, 'idx_categories_parent_id', 'parent_id')->addIndex(Key::TYPE_INDEX, 'idx_categories_level', 'level')->addIndex(Key::TYPE_INDEX, 'idx_categories_lft_rgt', array('lft', 'rgt'))->addIndex(Key::TYPE_INDEX, 'idx_categories_alias', 'alias')->addIndex(Key::TYPE_INDEX, 'idx_categories_created_by', 'created_by')->create(true); $record = new CategoryRecord(); $record->createRoot(); }