We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I am using migration docs to create migration but getting issue in release APK.
Below function is to make column unique
export const makeColumnUniqueInSQL = ( sql: string, tableName: string, colName: string, ) => { const modifiedSQL = sql.replace(`"${colName}"`, `"${colName}" unique`); return modifiedSQL; };
schema.ts
import {appSchema, tableSchema} from '@nozbe/watermelondb'; import {makeColumnUniqueInSQL, TableName} from './TableName'; export default appSchema({ version: 2, tables: [ tableSchema({ name: TableName.MESSAGES, columns: [ {name: 'server_id', type: 'string', isOptional: true}, // some other fields is here ], unsafeSql: (sql: string) => makeColumnUniqueInSQL(sql, TableName.MESSAGES, 'server_id'), }), ], });
migrations.ts
import { addColumns, schemaMigrations, } from '@nozbe/watermelondb/Schema/migrations'; import {TableName} from './TableName'; export default schemaMigrations({ migrations: [ { toVersion: 2, // minimum migration version is 2 steps: [ addColumns({ table: TableName.MESSAGES, columns: [{name: 'errors', type: 'string', isOptional: true}], unsafeSql: (sql: string) => { console.log('migration sql ', sql); return sql; }, }), ], }, ], });
index.ts
import {Database} from '@nozbe/watermelondb'; import SQLiteAdapter from '@nozbe/watermelondb/adapters/sqlite'; import Config from 'react-native-config'; import MessageModal from './modals/MessageModal'; import schema from './schema'; import migrations from './migrations'; const adapter = new SQLiteAdapter({ schema, migrations, dbName: Config.DB_NAME, }); export const database = new Database({ adapter, modelClasses: [MessageModal], });
But testing above changes in release APK migration is not running "Setting up database with schema version 2" is coming but it resetting the database.
NOTE : if I have remove unsafeSql makeColumnUniqueInSQL from schema.ts. then it's working fine.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am using migration docs to create migration but getting issue in release APK.
Below function is to make column unique
schema.ts
migrations.ts
index.ts
But testing above changes in release APK migration is not running "Setting up database with schema version 2" is coming but it resetting the database.
NOTE : if I have remove unsafeSql makeColumnUniqueInSQL from schema.ts. then it's working fine.
The text was updated successfully, but these errors were encountered: