From 66231b52d208cdb3cd062f6fd28a8432e45ce680 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Sun, 22 Sep 2019 21:23:09 +0100 Subject: [PATCH] started the logbook table --- .../migrations/024_add_column_logbookid.php | 2 +- .../migrations/025_create_logbook_table.php | 33 +++++++++++++++++++ .../026_addfield_to_logbooks_default.php | 20 +++++++++++ .../027_addfield_to_logbooks_active.php | 20 +++++++++++ .../migrations/028_logbooks_setkeys.php | 20 +++++++++++ 5 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 application/migrations/025_create_logbook_table.php create mode 100644 application/migrations/026_addfield_to_logbooks_default.php create mode 100644 application/migrations/027_addfield_to_logbooks_active.php create mode 100644 application/migrations/028_logbooks_setkeys.php diff --git a/application/migrations/024_add_column_logbookid.php b/application/migrations/024_add_column_logbookid.php index e8c23cc8..58147c4b 100644 --- a/application/migrations/024_add_column_logbookid.php +++ b/application/migrations/024_add_column_logbookid.php @@ -15,6 +15,6 @@ class Migration_add_column_logbookid extends CI_Migration { public function down() { - echo "Not possible, sorry."; + $this->dbforge->drop_column('logbook_id', $this->config->item('table_name')); } } \ No newline at end of file diff --git a/application/migrations/025_create_logbook_table.php b/application/migrations/025_create_logbook_table.php new file mode 100644 index 00000000..68151fab --- /dev/null +++ b/application/migrations/025_create_logbook_table.php @@ -0,0 +1,33 @@ +dbforge->add_field(array( + 'id' => array( + 'type' => 'INT', + 'constraint' => 5, + 'unsigned' => TRUE, + 'auto_increment' => TRUE + ), + 'logbook_name' => array( + 'type' => 'VARCHAR', + 'constraint' => '250', + ), + 'modified' => array( + 'type' => 'timestamp', + 'null' => TRUE, + ), + )); + $this->dbforge->add_key('id', TRUE); + $this->dbforge->create_table('logbooks'); + } + + public function down() + { + $this->dbforge->drop_table('logbooks'); + } +} \ No newline at end of file diff --git a/application/migrations/026_addfield_to_logbooks_default.php b/application/migrations/026_addfield_to_logbooks_default.php new file mode 100644 index 00000000..04ea5229 --- /dev/null +++ b/application/migrations/026_addfield_to_logbooks_default.php @@ -0,0 +1,20 @@ +dbforge->add_column('logbooks', $fields); + } + + public function down() + { + $this->dbforge->drop_column('default_logbook', 'logbooks'); + } +} \ No newline at end of file diff --git a/application/migrations/027_addfield_to_logbooks_active.php b/application/migrations/027_addfield_to_logbooks_active.php new file mode 100644 index 00000000..7a3146d7 --- /dev/null +++ b/application/migrations/027_addfield_to_logbooks_active.php @@ -0,0 +1,20 @@ +dbforge->add_column('logbooks', $fields); + } + + public function down() + { + $this->dbforge->drop_column('active_logbook', 'logbooks'); + } +} \ No newline at end of file diff --git a/application/migrations/028_logbooks_setkeys.php b/application/migrations/028_logbooks_setkeys.php new file mode 100644 index 00000000..12b5e155 --- /dev/null +++ b/application/migrations/028_logbooks_setkeys.php @@ -0,0 +1,20 @@ +db->db_debug = false; + $this->db->query("ALTER TABLE `logbooks` ADD UNIQUE(`id`);"); + $this->db->query("ALTER TABLE `logbooks` ADD INDEX(`id`);"); + $this->db->query("ALTER TABLE `logbooks` ADD INDEX(`logbook_name`);"); + $this->db->db_debug = true; + } + + public function down() + { + echo "Not possible, sorry."; + } +} \ No newline at end of file