I installed Directus 10 over an existing (TYPO3) projet and want to rename tables now. To do so, the Directus docs recommend to create a migration, which I did. There is a helper file with a constant that holds an array of the old and the new table names like this:
const { $renameTablesString } = [
{ origName: "tx_rwfm_domain_model_address_addresscategory_mm",
newName: "rwfm_mm_address_addresscategory;"},
{ origName: "tx_rwfm_domain_model_address_location_mm",
newName: "rwfm_mm_address_location;"},
{ origName: "tx_rwfm_domain_model_address_person_mm",
newName: "rwfm_mm_address_person;"},
...
]
This file is imported in the migration file and then lopped-over in the up
function that Directus requires to use:
import { $renameTablesString } from '../utils/rename-tables'
// Rename all tables
export async function up(knex) {
$renameTablesString.forEach(async item => {
await knex.schema
.renameTable(item.orig, item.newitem)
.dropTable(item.orig);
})
};
Upon running npx directus database migrate:up 2023-06-23__002__rename-tables.js
(from within a local Docker instance) I get this error message:
Migration keys collide! Please ensure that every migration uses a unique key.
Questions
- Why does this happen?
- What do I have to adapt to make this migration work?