Commit d96c6761 authored by Ahmad Abi Mulya's avatar Ahmad Abi Mulya

fix transaction entities

parent ab827c08
<component name="ProjectDictionaryState">
<dictionary name="ABI">
<words>
<w>transaksi</w>
</words>
</dictionary>
</component>
\ No newline at end of file
......@@ -17,11 +17,12 @@ import com.example.yourcashiertest.daos.ProductDao;
import com.example.yourcashiertest.daos.TransaksiDao;
import com.example.yourcashiertest.entities.Cart;
import com.example.yourcashiertest.entities.Product;
import com.example.yourcashiertest.entities.Transaksi;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Database(entities = {Product.class, Cart.class}, version = 4, exportSchema = false)
@Database(entities = {Product.class, Cart.class, Transaksi.class}, version = 4, exportSchema = false)
public abstract class LocalDatabase extends RoomDatabase {
public abstract ProductDao productDao();
......@@ -42,13 +43,6 @@ public abstract class LocalDatabase extends RoomDatabase {
}
};
public static final Migration MIGRATION_4_5 = new Migration(4, 5) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE IF NOT EXISTS Transaksi (orderId INTEGER NOT NULL, " +
"amount INTEGER NOT NULL, status TEXT NOT NULL, PRIMARY KEY(orderId))");
}
};
public static final Migration MIGRATION_2_3 = new Migration(2,3) {
@Override
......@@ -64,6 +58,13 @@ public abstract class LocalDatabase extends RoomDatabase {
}
};
public static final Migration MIGRATION_4_5 = new Migration(4, 5) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE IF NOT EXISTS Transaksi (orderId INTEGER NOT NULL, " +
"amount INTEGER NOT NULL, status TEXT NOT NULL, PRIMARY KEY(orderId))");
}
};
public static LocalDatabase getDatabase(Context context) {
if (INSTANCE == null) {
synchronized (LocalDatabase.class) {
......
......@@ -29,6 +29,12 @@ public class Transaksi implements Parcelable {
status = in.readString();
}
public Transaksi(long orderId, long amount, String status){
this.orderId = orderId;
this.amount = amount;
this.status = status;
}
public static final Creator<Transaksi> CREATOR = new Creator<Transaksi>() {
@Override
public Transaksi createFromParcel(Parcel in) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment