[Bands] Added migration script
这个提交包含在:
父节点
a7375c0bdc
当前提交
f133f1b6af
共有 2 个文件被更改,包括 164 次插入 和 1 次删除
|
|
@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
|
|||
| be upgraded / downgraded to.
|
||||
|
|
||||
*/
|
||||
$config['migration_version'] = 97;
|
||||
$config['migration_version'] = 98;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Migration_add_band_bandxuser extends CI_Migration {
|
||||
public function up()
|
||||
{
|
||||
if (!$this->db->table_exists('bands')) {
|
||||
$this->dbforge->add_field(array(
|
||||
'id' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => TRUE,
|
||||
'unique' => TRUE
|
||||
),
|
||||
|
||||
'band' => array(
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
)
|
||||
));
|
||||
|
||||
$this->dbforge->add_key('id', TRUE);
|
||||
|
||||
$this->dbforge->create_table('bands');
|
||||
|
||||
$this->db->query("INSERT INTO bands (band) values ('160m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('80m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('60m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('40m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('300m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('20m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('170m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('15m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('12m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('10m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('6m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('4m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('2m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('1.25m');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('70cm');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('33cm');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('23cm');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('13cm');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('9cm');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('6cm');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('3cm');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('1.25cm');");
|
||||
$this->db->query("INSERT INTO bands (band) values ('SAT');");
|
||||
}
|
||||
|
||||
if (!$this->db->table_exists('bandxuser')) {
|
||||
$this->dbforge->add_field(array(
|
||||
'id' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => TRUE,
|
||||
'unique' => TRUE
|
||||
),
|
||||
|
||||
'bandid' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
),
|
||||
|
||||
'userid' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
),
|
||||
|
||||
'active' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
),
|
||||
|
||||
'cq' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
),
|
||||
|
||||
'dok' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
),
|
||||
|
||||
'dxcc' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
),
|
||||
|
||||
'iota' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
),
|
||||
|
||||
'sig' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
),
|
||||
|
||||
'sota' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
),
|
||||
|
||||
'uscounties' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
),
|
||||
|
||||
'was' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
),
|
||||
|
||||
'vucc' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 20,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => FALSE
|
||||
),
|
||||
));
|
||||
|
||||
$this->dbforge->add_key('id', TRUE);
|
||||
|
||||
$this->dbforge->create_table('bandxuser');
|
||||
|
||||
$this->db->query("insert into bandxuser (bandid, userid, active, cq, dok, dxcc, iota, sig, sota, uscounties, was, vucc) select bands.id, users.user_id, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 from bands join users on 1 = 1;");
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dbforge->drop_table('bandxuser');
|
||||
$this->dbforge->drop_table('bands');
|
||||
}
|
||||
}
|
||||
正在加载…
在新工单中引用