mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
完善文章管理
This commit is contained in:
60
database/migrations/20200418120809_create_table_post.php
Normal file
60
database/migrations/20200418120809_create_table_post.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use app\common\ColumnFormat;
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class CreateTablePost extends Migrator
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('post',['comment'=>"内容文章"]);
|
||||
$table->addColumn(ColumnFormat::stringNormal('title')->setComment('标题'));
|
||||
$table->addColumn(ColumnFormat::stringUrl('poster')->setComment('封面'));
|
||||
$table->addColumn(ColumnFormat::timestamp('create_time'));
|
||||
$table->addColumn(ColumnFormat::timestamp('update_time'));
|
||||
$table->addColumn(ColumnFormat::timestamp('delete_time'));
|
||||
$table->addColumn(Column::make('content','text'));
|
||||
$table->addColumn(Column::make('content_html','text'));
|
||||
$table->addColumn(ColumnFormat::stringLong('desc')->setDefault('描述'));
|
||||
$table->addColumn(ColumnFormat::integerTypeStatus('is_top')->setComment('是否置顶'));
|
||||
$table->addColumn(ColumnFormat::integerTypeStatus('status')->setComment('1:显示,0:不显示'));
|
||||
$table->addColumn(ColumnFormat::timestamp('publish_time')->setComment('发表时间'));
|
||||
$table->addColumn(ColumnFormat::integer('hits')->setComment('访问量'));
|
||||
$table->addColumn(ColumnFormat::stringUrl('jump_to_url')->setComment('跳转链接'));
|
||||
$table->addColumn(ColumnFormat::integerTypeStatus('jump_to_url_status')->setComment('0:不显示,1:显示连接,2:自动跳转'));
|
||||
$table->addColumn(ColumnFormat::integer('sort')->setComment('排序,越大越靠前'));
|
||||
$table->addColumn(ColumnFormat::integerTypeStatus('type')->setComment('类型,1:文章,有分类有标签,2:页面,无分类无标签'));
|
||||
$table->addColumn(Column::make('files','text')->setComment('附件'));
|
||||
$table->addColumn(Column::make('pictures','text')->setComment('相册'));
|
||||
$table->addIndex('type');
|
||||
$table->addIndex('status');
|
||||
$table->addIndex('delete_time');
|
||||
$table->addIndex('hits');
|
||||
$table->addIndex('is_top');
|
||||
$table->create();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use app\common\ColumnFormat;
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class CreateTablePostCategory extends Migrator
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('post_category',['comment'=>'文章分类关联表']);
|
||||
$table->addColumn(ColumnFormat::integer('post_id'))
|
||||
->addColumn(ColumnFormat::integer('category_id'))
|
||||
->addColumn(ColumnFormat::timestamp('create_time'))
|
||||
->addColumn(ColumnFormat::timestamp('update_time'))
|
||||
->addColumn(ColumnFormat::timestamp('delete_time'))
|
||||
->addIndex('post_id')
|
||||
->addIndex('category_id')
|
||||
->create();
|
||||
|
||||
}
|
||||
}
|
||||
42
database/migrations/20200418120819_create_table_post_tag.php
Normal file
42
database/migrations/20200418120819_create_table_post_tag.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use app\common\ColumnFormat;
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class CreateTablePostTag extends Migrator
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('post_tag',['comment'=>'文章分类关联表']);
|
||||
$table->addColumn(ColumnFormat::integer('post_id'))
|
||||
->addColumn(ColumnFormat::integer('tag_id'))
|
||||
->addColumn(ColumnFormat::timestamp('create_time'))
|
||||
->addColumn(ColumnFormat::timestamp('update_time'))
|
||||
->addColumn(ColumnFormat::timestamp('delete_time'))
|
||||
->addIndex('post_id')
|
||||
->addIndex('tag_id')
|
||||
->create();
|
||||
}
|
||||
}
|
||||
43
database/migrations/20200418120827_create_table_category.php
Normal file
43
database/migrations/20200418120827_create_table_category.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use app\common\ColumnFormat;
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class CreateTableCategory extends Migrator
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('category')
|
||||
->setComment('分类表')
|
||||
->addColumn(ColumnFormat::stringNormal('title'))
|
||||
->addColumn(ColumnFormat::timestamp('create_time'))
|
||||
->addColumn(ColumnFormat::timestamp('update_time'))
|
||||
->addColumn(ColumnFormat::timestamp('delete_time'))
|
||||
->addColumn(ColumnFormat::integer('pid')->setComment('上级id'))
|
||||
->addColumn(ColumnFormat::integer('level')->setDefault(1)->setComment('层级'))
|
||||
->addIndex('pid')
|
||||
->create();
|
||||
}
|
||||
}
|
||||
40
database/migrations/20200418120831_create_table_tag.php
Normal file
40
database/migrations/20200418120831_create_table_tag.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use app\common\ColumnFormat;
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class CreateTableTag extends Migrator
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('tag')
|
||||
->setComment('分类表')
|
||||
->addColumn(ColumnFormat::stringNormal('title'))
|
||||
->addColumn(ColumnFormat::timestamp('create_time'))
|
||||
->addColumn(ColumnFormat::timestamp('update_time'))
|
||||
->addColumn(ColumnFormat::timestamp('delete_time'))
|
||||
->create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user