react-native-quick-sqlite icon indicating copy to clipboard operation
react-native-quick-sqlite copied to clipboard

Unable to generate migration

Open L-U-C-K-Y opened this issue 9 months ago • 2 comments

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

import { typeORMDriver } from 'react-native-quick-sqlite';
import { DataSource } from 'typeorm';

const dataSource = new DataSource({
  type: 'react-native',
  database: 'typeormdb',
  location: '.',
  driver: typeORMDriver,
  entities: [
    // entities
  ],
  logging: true,
  // synchronize: true, // only have it in dev, otherwise use migrations!
  migrations: [],
  migrationsRun: true,
});

export default dataSource;

Commands:

typeorm migration:generate -d src/db/dataSource/index.ts src/db/migrations
npx typeorm-ts-node-commonjs migration:generate -d src/db/dataSource/index.ts src/db/migrations
npx typeorm-ts-node-esm migration:generate -d src/db/dataSource/index.ts src/db/migrations
npx typeorm migration:generate -d ./src/db/dataSource/index.ts ./src/db/migrations

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.

L-U-C-K-Y avatar Sep 16 '23 15:09 L-U-C-K-Y