Skip to content

Commit 0eee5f7

Browse files
committed
字段信息列表中增加is_code字段设置
1 parent 631990c commit 0eee5f7

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"topthink/framework": "^6.1.0",
1515
"topthink/think-orm": "^2.0",
1616
"topthink/think-filesystem": "^1.0",
17-
"vuecmf/framework": "^2.1"
17+
"vuecmf/framework": "^2.2"
1818
},
1919
"require-dev": {
2020
"symfony/var-dumper": "^4.2",
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
use think\migration\Migrator;
4+
use think\migration\db\Column;
5+
6+
class UpdateModelField extends Migrator
7+
{
8+
/**
9+
* Change Method.
10+
*
11+
* Write your reversible migrations using this method.
12+
*
13+
* More information on writing migrations is available here:
14+
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
15+
*
16+
* The following commands can be used in this method and Phinx will
17+
* automatically reverse them when rolling back:
18+
*
19+
* createTable
20+
* renameTable
21+
* addColumn
22+
* renameColumn
23+
* addIndex
24+
* addForeignKey
25+
*
26+
* Remember to call "create()" or "update()" and NOT "save()" when working
27+
* with the Table class.
28+
* biginteger
29+
binary
30+
boolean
31+
date
32+
datetime
33+
decimal
34+
float
35+
integer
36+
string
37+
text
38+
time
39+
timestamp
40+
uuid
41+
*/
42+
public function up()
43+
{
44+
$this->table('model_field')
45+
->addColumn('is_code', 'integer', ['length' => 255, 'null' => false, 'default' => 20, 'comment' => '是否显示文本源码,10=是,20=否','after' => 'is_filter'])
46+
->update();
47+
48+
//写入初始数据
49+
//model_field 字段表
50+
$data = [
51+
['id' => 247,'field_name' => 'is_code','label' => '显示源码','model_id' => 3,'type' => 'smallint','length' => 4,'decimal_length' => 0,'is_null' => 20,'note' => '是否显示文本源码,10=是,20=否','default_value' => '20','is_auto_increment' => 20,'is_label' => 20,'is_signed' => 20,'is_show' => 10,'is_fixed' => 20,'column_width' => 100,'is_filter' => 10,'sort_num' => 34,'status' => 10,],
52+
];
53+
$this->table('model_field')->insert($data)->save();
54+
55+
//field_option 字段选项表
56+
$data = [
57+
['model_id' => 3,'model_field_id' => 247,'type' => 10,'option_value' => '10','option_label' => '',],
58+
['model_id' => 3,'model_field_id' => 247,'type' => 10,'option_value' => '20','option_label' => '',],
59+
];
60+
$this->table('field_option')->insert($data)->save();
61+
62+
//model_form 模型表单表
63+
$data = [
64+
['id' => 265,'model_id' => 3,'model_field_id' => 247,'type' => 'radio','default_value' => '20','is_disabled' => 20,'sort_num' => 55,'status' => 10,],
65+
];
66+
$this->table('model_form')->insert($data)->save();
67+
68+
}
69+
70+
public function down()
71+
{
72+
$this->table('model_field')->removeColumn('is_code')->save();
73+
74+
$this->execute('delete from '.config('database.connections.mysql.prefix').'model_field where id = 247;');
75+
$this->execute('delete from '.config('database.connections.mysql.prefix').'field_option where model_field_id = 247;');
76+
$this->execute('delete from '.config('database.connections.mysql.prefix').'model_form where id = 265;');
77+
}
78+
}

0 commit comments

Comments
 (0)