Fix migrations
This commit is contained in:
parent
75e79394f2
commit
bad3e58fbd
@ -39,7 +39,7 @@ import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt;
|
|||||||
InventarioRoomDTO.class,
|
InventarioRoomDTO.class,
|
||||||
InventarioRowRoomDTO.class
|
InventarioRowRoomDTO.class
|
||||||
},
|
},
|
||||||
version = 15,
|
version = 11,
|
||||||
exportSchema = true)
|
exportSchema = true)
|
||||||
@TypeConverters({
|
@TypeConverters({
|
||||||
DateConverter.class,
|
DateConverter.class,
|
||||||
@ -63,11 +63,7 @@ public abstract class AppDatabase extends RoomDatabase {
|
|||||||
if (sInstance == null) {
|
if (sInstance == null) {
|
||||||
var builder = Room.databaseBuilder(applicationContext,
|
var builder = Room.databaseBuilder(applicationContext,
|
||||||
AppDatabase.class, "integry_wms")
|
AppDatabase.class, "integry_wms")
|
||||||
.addMigrations(MIGRATION_10_11)
|
.addMigrations(MIGRATION_10_11);
|
||||||
.addMigrations(MIGRATION_11_12)
|
|
||||||
.addMigrations(MIGRATION_12_13)
|
|
||||||
.addMigrations(MIGRATION_13_14)
|
|
||||||
.addMigrations(MIGRATION_14_15);
|
|
||||||
|
|
||||||
sInstance = builder.build();
|
sInstance = builder.build();
|
||||||
}
|
}
|
||||||
@ -94,40 +90,16 @@ public abstract class AppDatabase extends RoomDatabase {
|
|||||||
static final Migration MIGRATION_10_11 = new Migration(10, 11) {
|
static final Migration MIGRATION_10_11 = new Migration(10, 11) {
|
||||||
@Override
|
@Override
|
||||||
public void migrate(SupportSQLiteDatabase database) {
|
public void migrate(SupportSQLiteDatabase database) {
|
||||||
database.execSQL("CREATE TABLE IF NOT EXISTS inventari (_id INTEGER PRIMARY KEY AUTOINCREMENT, cod_mdep TEXT NOT NULL, data_inventario INTEGER, data_reg INTEGER, data_ver INTEGER, filtro TEXT, flag_stato TEXT, flag_operazione TEXT, cod_anag TEXT, cod_dtip TEXT, inserito_da TEXT, registrato_da TEXT, verificato_da TEXT, data_ora_inizio INTEGER, data_ora_fine INTEGER, causale TEXT, remote_sync_date INTEGER)");
|
database.execSQL("CREATE TABLE IF NOT EXISTS inventari (_id INTEGER PRIMARY KEY AUTOINCREMENT, id_inventario INTEGER, cod_mdep TEXT NOT NULL, zona TEXT, data_inventario INTEGER, data_reg INTEGER, data_ver INTEGER, filtro TEXT, flag_stato TEXT, flag_operazione TEXT, cod_anag TEXT, cod_dtip TEXT, inserito_da TEXT, registrato_da TEXT, verificato_da TEXT, data_ora_inizio INTEGER, data_ora_fine INTEGER, causale TEXT, remote_sync_date INTEGER)");
|
||||||
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventari__id ON inventari (_id)");
|
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventari__id ON inventari (_id)");
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static final Migration MIGRATION_11_12 = new Migration(11, 12) {
|
|
||||||
@Override
|
|
||||||
public void migrate(SupportSQLiteDatabase database) {
|
|
||||||
database.execSQL("ALTER TABLE inventari ADD COLUMN id_inventario INTEGER");
|
|
||||||
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventari_id_inventario ON inventari (id_inventario)");
|
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventari_id_inventario ON inventari (id_inventario)");
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static final Migration MIGRATION_12_13 = new Migration(12, 13) {
|
|
||||||
@Override
|
|
||||||
public void migrate(SupportSQLiteDatabase database) {
|
|
||||||
database.execSQL("ALTER TABLE inventari ADD COLUMN zona TEXT");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static final Migration MIGRATION_13_14 = new Migration(13, 14) {
|
database.execSQL("CREATE TABLE IF NOT EXISTS inventario_rows (_id INTEGER PRIMARY KEY AUTOINCREMENT, parent_id INTEGER, cod_mart TEXT NOT NULL, descrizione TEXT, partita_mag TEXT, qta REAL NOT NULL DEFAULT 0, num_cnf REAL NOT NULL DEFAULT 0, qta_cnf REAL NOT NULL DEFAULT 0, unt_mis TEXT NOT NULL DEFAULT '0', data_ora_inv INTEGER, scan_cod_barre TEXT, zona TEXT, remote_sync_date INTEGER, FOREIGN KEY(parent_id) REFERENCES inventari(_id) ON UPDATE NO ACTION ON DELETE NO ACTION )");
|
||||||
@Override
|
|
||||||
public void migrate(SupportSQLiteDatabase database) {
|
|
||||||
database.execSQL("CREATE TABLE IF NOT EXISTS inventario_rows (_id INTEGER PRIMARY KEY AUTOINCREMENT, parent_id INTEGER, cod_mart TEXT NOT NULL, partita_mag TEXT, qta REAL NOT NULL DEFAULT 0, num_cnf REAL NOT NULL DEFAULT 0, qta_cnf REAL NOT NULL DEFAULT 0, unt_mis TEXT NOT NULL DEFAULT '0', data_ora_inv INTEGER, scan_cod_barre TEXT, zona TEXT, remote_sync_date INTEGER, FOREIGN KEY(parent_id) REFERENCES inventari(_id) ON UPDATE NO ACTION ON DELETE NO ACTION )");
|
|
||||||
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventario_rows__id ON inventario_rows (_id)");
|
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventario_rows__id ON inventario_rows (_id)");
|
||||||
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventario_rows__parent_id ON inventario_rows (parent_id)");
|
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventario_rows__parent_id ON inventario_rows (parent_id)");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static final Migration MIGRATION_14_15 = new Migration(14, 15) {
|
|
||||||
@Override
|
|
||||||
public void migrate(SupportSQLiteDatabase database) {
|
|
||||||
database.execSQL("ALTER TABLE inventario_rows ADD COLUMN descrizione TEXT");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user