createTable( 'variant', [ 'id' => $this->primaryKey(), 'product_id' => $this->integer() ->notNull(), 'sku' => $this->string() ->notNull(), 'price' => $this->decimal(), 'price_old' => $this->decimal(), 'stock' => $this->integer() ->notNull() ->defaultValue(0), 'status' => $this->boolean() ->defaultValue(true), 'sort' => $this->integer() ->defaultValue(0), 'created_at' => $this->integer(), 'updated_at' => $this->integer(), ] ); $this->addForeignKey( 'variant_product_id_to_product_fk', 'variant', 'product_id', 'product', 'id', 'CASCADE', 'CASCADE' ); } public function safeDown() { $this->dropForeignKey( 'variant_product_id_to_product_fk', 'variant' ); $this->dropTable('variant'); } }