我正在为我的应用程序编写大量数据库迁移脚本。我想为专栏添加评论,以便其他人可以轻松识别专栏的内容。一种选择是编写普通的 SQL 查询并添加注释。但是有没有办法在迁移脚本中添加这些注释?
$this->dbforge->add_field(array(
'post_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
'comment' => 'Unique post id'
),
'user_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
),
'group_id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
),
'source' => array(
'type' => 'VARCHAR',
'constraint' => 20
),
'data' => array(
'type' => 'TEXT',
),
'created' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
),
'updated' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
),
'status' => array(
'type' => 'INT',
'constraint' => 1,
'unsigned' => true,
)
));
这是我编写的基本代码。可能有一些语法错误。但我只是复制粘贴它。
谁能帮忙。
最佳答案
CodeIgniter 在 3.0 版本中添加了这个功能。您可以使用“评论”键添加评论:
'first_name' => [
'type' => 'VARCHAR',
'constraint' => 45,
'null' => false,
'comment' => 'Put the field comment here',
]
关于mysql - 在 codeigniter 迁移中向列添加注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16620650/