โดย Ittichai_chupol » 12/10/2018 6:38 pm
โค้ด: เลือกทั้งหมด
<?php
namespace mindphp\sample1\migrations;
class install_sample1 extends \phpbb\db\migration\migration {
public function effectively_installed() {
return isset($this->config['sample1_version']) && version_compare($this->config['sample1'], '1.0.0', '>=');
}
static public function depends_on() {
return array('\phpbb\db\migration\data\v310\dev');
}
public function update_schema() {
return array
(
'add_tables' => array(
$this->table_prefix . 'sample1' => array(
'COLUMNS' => array(
'id' => array('UINT:11', null, 'auto_increment'),
'usertel_id' => array('UINT:11', 0),
'username' => array('VCHAR:100', ''),
'password' => array('VCHAR:100', ''),
'tell' => array('VCHAR:100', ''),
'pass_duplicate' => array('UINT:11', 0),
),
'PRIMARY_KEY' => 'id',
),
),
);
}
public function revert_schema() {
return array(
'drop_tables' => array(
$this->table_prefix . 'sample1',
),
);
}
public function update_data() {
return array(
array('config.add', array('tmb_newa_userid', '1')),
array('config.add', array('tmb_newa_usergroup', '')),
);
}
}
[code]
<?php
namespace mindphp\sample1\migrations;
class install_sample1 extends \phpbb\db\migration\migration {
public function effectively_installed() {
return isset($this->config['sample1_version']) && version_compare($this->config['sample1'], '1.0.0', '>=');
}
static public function depends_on() {
return array('\phpbb\db\migration\data\v310\dev');
}
public function update_schema() {
return array
(
'add_tables' => array(
$this->table_prefix . 'sample1' => array(
'COLUMNS' => array(
'id' => array('UINT:11', null, 'auto_increment'),
'usertel_id' => array('UINT:11', 0),
'username' => array('VCHAR:100', ''),
'password' => array('VCHAR:100', ''),
'tell' => array('VCHAR:100', ''),
'pass_duplicate' => array('UINT:11', 0),
),
'PRIMARY_KEY' => 'id',
),
),
);
}
public function revert_schema() {
return array(
'drop_tables' => array(
$this->table_prefix . 'sample1',
),
);
}
public function update_data() {
return array(
array('config.add', array('tmb_newa_userid', '1')),
array('config.add', array('tmb_newa_usergroup', '')),
);
}
}
[/code]