Added default papers to migration-script

这个提交包含在:
int2001 2023-08-02 11:05:27 +00:00
父节点 d5b8204e57
当前提交 6cdb88d26d
找不到此签名对应的密钥
GPG 密钥 ID: DFB1C13CD2DB037B

查看文件

@ -5,59 +5,63 @@ defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_create_label_paper_types_table extends CI_Migration { class Migration_create_label_paper_types_table extends CI_Migration {
public function up() { public function up() {
if (!$this->db->table_exists('paper_types')) { if (!$this->db->table_exists('paper_types')) {
$this->dbforge->add_field(array( $this->dbforge->add_field(array(
'id' => array( 'id' => array(
'type' => 'INT', 'type' => 'INT',
'constraint' => 5, 'constraint' => 5,
'unsigned' => TRUE, 'unsigned' => TRUE,
'auto_increment' => TRUE 'auto_increment' => TRUE
), ),
'user_id' => array( 'user_id' => array(
'type' => 'INT', 'type' => 'INT',
'constraint' => 5, 'constraint' => 5,
), ),
'paper_name' => array( 'paper_name' => array(
'type' => 'VARCHAR', 'type' => 'VARCHAR',
'constraint' => '250', 'constraint' => '250',
), ),
'metric' => array( 'metric' => array(
'type' => 'VARCHAR', 'type' => 'VARCHAR',
'constraint' => '10', 'constraint' => '10',
), ),
'width' => array( 'width' => array(
'type' => 'DECIMAL', 'type' => 'DECIMAL',
'constraint' => '6,3', 'constraint' => '6,3',
'null' => TRUE, 'null' => TRUE,
), ),
'orientation' => array( 'orientation' => array(
'type' => 'VARCHAR', 'type' => 'VARCHAR',
'constraint' => '1', 'constraint' => '1',
'null' => TRUE, 'null' => TRUE,
), ),
'height' => array( 'height' => array(
'type' => 'DECIMAL', 'type' => 'DECIMAL',
'constraint' => '6,3', 'constraint' => '6,3',
'null' => TRUE, 'null' => TRUE,
), ),
'last_modified' => array( 'last_modified' => array(
'type' => 'timestamp', 'type' => 'timestamp',
'null' => TRUE, 'null' => TRUE,
), ),
)); ));
$this->dbforge->add_key('id', TRUE); $this->dbforge->add_key('id', TRUE);
$this->dbforge->add_key('user_id', TRUE); $this->dbforge->add_key('user_id', TRUE);
$this->dbforge->create_table('paper_types'); $this->dbforge->create_table('paper_types');
} $this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('1','1','A4','mm','210.000','P','297.000');");
$this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('2','1','A5','mm','148.000','P','210.000');");
$this->db->query("insert into paper_types (id,user_id,paper_name,metric,width,orientation,height) values ('3','1','letter','mm','215.900','P','279.400');");
$this->db->query("insert ignore paper_types (user_id,paper_name,metric,width,orientation,height) SELECT u.user_id, pt.paper_name, pt.metric, pt.width, pt.orientation,pt.height FROM paper_types pt inner join users u where pt.id<4;");
}
} }