Im been searching around on how to migrate changes from increments()
to bigIncrements()
using existing tables.
Error : SQLSTATE[HY000]: General error: 1833 Cannot change column 'id': used in a foreign key constraint 'account_users_acc_id_foreign' of table 'mydatabasename.account_users' (SQL: ALTER TABLE accounts CHANGE id id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL)
i tried to disabled constraint using Schema::disableForeignKeyConstraints()
Error : SQLSTATE[HY000]: General error: 1025 Error on rename of './mydatabasename/#sql-ea_201' to './mydatabasename/accounts' (errno: 150 - Foreign key constraint is incorrectly formed) (SQL: ALTER TABLE accounts CHANGE id id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL)
in my up()
function:
$connection = Schema::getConnection()->getDoctrineSchemaManager();
$tables = $connection->listTableNames();
// get all tables
foreach ($tables as $current) {
//change integer to biginteger
Schema::table($current, function (Blueprint $table) use ($connection) {
$table->bigIncrements('id')->change();
});
}
foreach ($tables as $current) {
Schema::table($current, function (Blueprint $table) use ($connection) {
foreach ($connection->listTableForeignKeys($table->getTable()) as $foreignKey) {
$table->unsignedBigInteger($foreignKey->getLocalColumns()[0])->change();
}
});
}
Is there anywhere to solve this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire