cycle / schema-builder

Declarative schema generation for Cycle ORM
MIT License
15 stars 11 forks source link

Two mirrored unique indexes gets generated in pivot table #19

Closed anlamas closed 2 years ago

anlamas commented 3 years ago

2 unique indexes gets generated in pivot table

unique(product_category_id, product_id)
unique(product_id, product_category_id)
$this->table('product_product_category')
            ->addColumn('id', 'bigPrimary', [
                'nullable' => false,
                'default'  => null
            ])
            ->addColumn('product_category_id', 'bigInteger', [
                'nullable' => false,
                'default'  => null
            ])
            ->addColumn('product_id', 'bigInteger', [
                'nullable' => false,
                'default'  => null
            ])
            ->addIndex(["product_category_id", "product_id"], [
                'name'   => '0e92fceae82e7e0e91d346a72bf831ae',
                'unique' => true
            ])
            ->addIndex(["product_category_id"], [
                'name'   => 'product_product_category_index_product_category_id_6035f3284ea68',
                'unique' => false
            ])
            ->addIndex(["product_id"], [
                'name'   => 'product_product_category_index_product_id_6035f3284ea79',
                'unique' => false
            ])
            ->addIndex(["product_id", "product_category_id"], [
                'name'   => '642dad4db053452e89cb383adbe9089f',
                'unique' => true
            ])
            ->addForeignKey(["product_category_id"], 'product_categories', ["id"], [
                'name'   => '4c20a9d910d4f5d5ffa685a41db81ccc',
                'delete' => 'CASCADE',
                'update' => 'CASCADE'
            ])
            ->addForeignKey(["product_id"], 'products', ["id"], [
                'name'   => 'product_product_category_foreign_product_id_6035f3284ea75',
                'delete' => 'CASCADE',
                'update' => 'CASCADE'
            ])
            ->setPrimaryKeys(["id"])
            ->create();