-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathM4_AddUuid.cs
More file actions
58 lines (45 loc) · 1.24 KB
/
M4_AddUuid.cs
File metadata and controls
58 lines (45 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using SQLite;
namespace TimeTracker.Database.Migrations;
public class M4_AddUuid : IDbMigration
{
public async Task Do(SQLiteAsyncConnection db)
{
await db.ExecuteAsync("ALTER TABLE TrackedTimeDb ADD Uuid text");
var all = await db.Table<TrackedTimeDb_M004>().ToListAsync();
foreach (var trackedTimeDb in all)
{
trackedTimeDb.Uuid = Guid.NewGuid();
await db.UpdateAsync(trackedTimeDb);
}
}
public Task UnDo(SQLiteAsyncConnection db)
{
throw new NotImplementedException();
}
public string Serialize()
{
throw new NotImplementedException();
}
}
/// <summary>
/// Data model at the time of migration <see cref="M4_AddUuid"/>
/// </summary>
[Table(nameof(TrackedTimeDb))]
public class TrackedTimeDb_M004 : ITable
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public Guid Uuid { get; set; }
public string Name { get; set; }
public DateTime StartTime { get; set; }
public TimeSpan ElapsedTime { get; init; }
public int Status { get; set; }
public enum TrackingStatus
{
Completed = 0,
/// <summary>
/// Currently running
/// </summary>
Running = 1,
}
}