-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to generate migration #18
Comments
Small update, I was temporarily able to create migrations with a workaround by creating a second sqlite datasource and running the migrations against that. I then imported (no glob pattern) the migrations into the main data source and the migrations were applied. Let me know if we can keep it open. Maybe there is just no possibility to create migrations against the sqlite database in react-native. |
Thanks @L-U-C-K-Y, this was helpful. I've taken the same approach and used a separate local db to manage the migrations. So we have two data sources: // dataSource.ts
export const dataSource = new DataSource({
type: 'react-native',
database: DB_NAME,
location: '.',
driver: typeORMDriver,
entities,
migrations: [InitialSchema1697806995951, Test1697809356693],
}); // migrationsDataSource.ts
const DB_NAME = path.join(__dirname, 'migrations', 'driver.local.sqlite');
// eslint-disable-next-line no-new
new sqlite3.Database(DB_NAME);
export const migrationsDataSource = new DataSource({
type: 'sqlite',
database: DB_NAME,
entities,
migrations: [path.join(__dirname, './migrations/*.ts')],
}); In package.json i set the following: "typeorm": "typeorm-ts-node-commonjs", And generate the migrations on the local db in node.js: npm run typeorm -- migration:generate -d db/migrationsDataSource.ts db/migrations/MigrationName To apply the migrations to the app db, I run migrations in the app with |
@badsyntax @L-U-C-K-Y Thank you very much, This really worked for me, I've been struggling with this issue for days, This was really helpful |
Many thanks for providing and maintaining this awesome library!
I have followed the docs and was successful to set it up and write/read data from sqlite with TypeORM.
I am trying to generate a migration for production but I am struggling with getting it to run.
Does anyone has advice how to implement a migration?
Here are things that I have tried.
dataSource.ts
Commands:
Thanks a lot
Edit: After running a few more experiments I was able to narrow the problem down to the typeORM driver.
Using exactly the same setup without the typeORM driver and postgres is working!
The app is running fine overall, reading and writing is working, but generation of the migration is not working.
The text was updated successfully, but these errors were encountered: