-
Notifications
You must be signed in to change notification settings - Fork 11
/
Migration.cs
34 lines (32 loc) · 1.19 KB
/
Migration.cs
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
using System;
using System.Security.Cryptography;
using System.Text;
namespace Mite.Core
{
public class Migration : IComparable
{
private readonly string version;
private readonly string upSql;
private readonly string downSql;
private readonly string hash;
public Migration(string version, string upSql, string downSql)
{
this.version = version;
this.upSql = upSql;
this.downSql = downSql;
var crypto = new SHA1CryptoServiceProvider();
this.hash = Convert.ToBase64String(crypto.ComputeHash(Encoding.UTF8.GetBytes(upSql + downSql)));
}
public string Hash { get { return hash; } }
public string Version { get { return version; } }
public string UpSql { get { return upSql; } }
public string DownSql { get { return downSql; } }
public int CompareTo(object obj)
{
var comparable = (Migration) obj;
if (comparable.Hash == this.Hash)
return 0;
return (comparable).Version.CompareTo(this.Version); //string comparison works fine for ISO8611
}
}
}