Welcome Guest, Not a member yet? Register   Sign In
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


Messages In This Thread
Help with Migration - by phpforever2017 - 05-24-2017, 07:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB