• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with Migration

#1
Hello guys!

When I run migration with this code, up or down
PHP Code:
class Migration_add_field_to_products_to_attribute extends CI_Migration {
 
   public function up()
 
   {
 
       $this->db->query("ALTER TABLE `products_to_attribute` ADD `attribute_group_id` INT UNSIGNED NOT NULL AFTER `product_id`;");

 
       $this->db->query("ALTER TABLE `products_to_attribute` ADD `attribute_id` INT UNSIGNED NOT NULL AFTER `attribute_group_id`;");

 
       $this->db->query("ALTER TABLE `products_to_attribute` DROP PRIMARY KEY");

 
       $this->db->query("ALTER TABLE `products_to_attribute` ADD PRIMARY KEY( `product_id`, `attribute_group_id`, `attribute_id`, `attribute_value_id`);");
 
       
    
}

 
   public function down()
 
   {
 
       $this->db->query("ALTER TABLE `stels_products_to_attribute` DROP `attribute_group_id`;");

 
       $this->db->query("ALTER TABLE `stels_products_to_attribute` DROP `attribute_id`;");
 
   }

I get this error
PHP Code:
Database errorA Database Error Occurred

        Error Number
1068
        Multiple primary key defined
        ALTER TABLE 
`products_to_attributeADD PRIMARY KEY (`product_id`,`attribute_value_id`);
 
       FilenameC:/dev/dev_velta/system/database/DB_driver.php
        Line Number
691 
In the database keys was update, but in migrations table [url=http://localhost/phpmyadmin/sql.php?db=velta_db&table=stels_migrations&token=e196bff20545a81bd141c3f257b8bec7][/url]don't update migration version

Thanks! Sorry for my english
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.