Skip to content

Instantly share code, notes, and snippets.

@rsmarshall
Created May 17, 2012 09:57
Show Gist options
  • Save rsmarshall/2717868 to your computer and use it in GitHub Desktop.
Save rsmarshall/2717868 to your computer and use it in GitHub Desktop.
example migration
<?php
class Migration_Mapping_tables extends Migration {
public function up()
{
$this->load->dbforge();
// Create stock feed mapping table
$this->dbforge->add_field('supplier_id TINYINT(2) UNSIGNED NOT NULL AUTO_INCREMENT');
$this->dbforge->add_field('sku TINYINT(2) NOT NULL');
$this->dbforge->add_field('supplier_code TINYINT(2) NOT NULL');
$this->dbforge->add_field('cost TINYINT(2) NOT NULL');
$this->dbforge->add_field('stock TINYINT(2) NOT NULL');
$this->dbforge->add_field('eta TINYINT(2) NOT NULL');
$this->dbforge->add_key('supplier_id', TRUE);
$this->dbforge->create_table('supplier_stock_mapping');
// Create full feed mapping table
$this->dbforge->add_field('supplier_id TINYINT(2) UNSIGNED NOT NULL AUTO_INCREMENT');
$this->dbforge->add_field('sku TINYINT(2) NOT NULL');
$this->dbforge->add_field('supplier_code TINYINT(2) NOT NULL');
$this->dbforge->add_field('cost TINYINT(2) NOT NULL');
$this->dbforge->add_field('stock TINYINT(2) NOT NULL');
$this->dbforge->add_field('eta TINYINT(2) NOT NULL');
$this->dbforge->add_field('brand TINYINT(2) NOT NULL');
$this->dbforge->add_field('product_name TINYINT(2) NOT NULL');
$this->dbforge->add_field('category TINYINT(2) NOT NULL');
$this->dbforge->add_field('description TINYINT(2) NOT NULL');
$this->dbforge->add_field('barcode TINYINT(2) NOT NULL');
$this->dbforge->add_field('weight TINYINT(2) NOT NULL');
$this->dbforge->add_field('jshop_id TINYINT(2) NOT NULL');
$this->dbforge->add_key('supplier_id', TRUE);
$this->dbforge->create_table('supplier_full_mapping');
}
public function down()
{
$prefix = $this->db->dbprefix;
$sql = "DROP TABLE {$prefix}supplier_stock_mapping,{$prefix}supplier_full_mapping";
return $sql;
}
}
/* End of file: 003_Mapping_tables.php */
/* Location: /bonfire/modules/suppliers/migrations/003_Mapping_tables.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment