Merge branch 'databaseChanges' into 'master'
Database changes See merge request famedly/famedlysdk!6
This commit is contained in:
commit
3a3af4235b
|
@ -54,19 +54,16 @@ class Store {
|
||||||
String path = p.join(databasePath, "FluffyMatrix.db");
|
String path = p.join(databasePath, "FluffyMatrix.db");
|
||||||
_db = await openDatabase(path, version: 2,
|
_db = await openDatabase(path, version: 2,
|
||||||
onCreate: (Database db, int version) async {
|
onCreate: (Database db, int version) async {
|
||||||
// When creating the db, create the table
|
await createTables(db);
|
||||||
await db.execute(ClientsScheme);
|
|
||||||
await db.execute(RoomsScheme);
|
|
||||||
await db.execute(ParticipantsScheme);
|
|
||||||
await db.execute(EventsScheme);
|
|
||||||
},
|
},
|
||||||
onUpgrade: (Database db, int oldVersion, int newVersion) async{
|
onUpgrade: (Database db, int oldVersion, int newVersion) async{
|
||||||
if (oldVersion != newVersion) {
|
if (oldVersion != newVersion) {
|
||||||
await db.rawDelete("DELETE FROM Rooms");
|
await db.execute("DROP TABLE IF EXISTS Rooms");
|
||||||
await db.rawDelete("DELETE FROM Participants");
|
await db.execute("DROP TABLE IF EXISTS Participants");
|
||||||
await db.rawDelete("DELETE FROM Events");
|
await db.execute("DROP TABLE IF EXISTS Events");
|
||||||
db.rawUpdate("UPDATE Clients SET prev_batch='' WHERE client=?",
|
db.rawUpdate("UPDATE Clients SET prev_batch='' WHERE client=?",
|
||||||
[client.clientName]);
|
[client.clientName]);
|
||||||
|
createTables(db);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -89,6 +86,14 @@ class Store {
|
||||||
client.connection.onLoginStateChanged.add(LoginState.loggedOut);
|
client.connection.onLoginStateChanged.add(LoginState.loggedOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Future<void> createTables(Database db) async{
|
||||||
|
await db.execute(ClientsScheme);
|
||||||
|
await db.execute(RoomsScheme);
|
||||||
|
await db.execute(ParticipantsScheme);
|
||||||
|
await db.execute(EventsScheme);
|
||||||
|
}
|
||||||
|
|
||||||
Future<String> queryPrevBatch() async{
|
Future<String> queryPrevBatch() async{
|
||||||
List<Map> list = await txn.rawQuery("SELECT prev_batch FROM Clients WHERE client=?", [client.clientName]);
|
List<Map> list = await txn.rawQuery("SELECT prev_batch FROM Clients WHERE client=?", [client.clientName]);
|
||||||
return list[0]["prev_batch"];
|
return list[0]["prev_batch"];
|
||||||
|
|
|
@ -52,7 +52,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Formatting", () async {
|
test("Formatting", () async {
|
||||||
final int timestamp = 1560144984758;
|
final int timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||||
final ChatTime chatTime = ChatTime(timestamp);
|
final ChatTime chatTime = ChatTime(timestamp);
|
||||||
//expect(chatTime.toTimeString(),"05:36"); // This depends on the time and your timezone ;)
|
//expect(chatTime.toTimeString(),"05:36"); // This depends on the time and your timezone ;)
|
||||||
expect(chatTime.toTimeString(),chatTime.toEventTimeString());
|
expect(chatTime.toTimeString(),chatTime.toEventTimeString());
|
||||||
|
|
Loading…
Reference in a new issue