diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-18 04:28:39 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-18 04:28:39 -0500 |
| commit | 9f40c1982bf2b63d2779a8971361364772e33298 (patch) | |
| tree | 923d86c9da1aa1ec6c683a21820e4cd9076cd385 /Emby.Server.Implementations/Data/BaseSqliteRepository.cs | |
| parent | fa714425dd91fed2ca691cd45f73f7ea5a579dff (diff) | |
rework additional repositories
Diffstat (limited to 'Emby.Server.Implementations/Data/BaseSqliteRepository.cs')
| -rw-r--r-- | Emby.Server.Implementations/Data/BaseSqliteRepository.cs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs index c7ac630a0..8febe83b2 100644 --- a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs +++ b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs @@ -69,7 +69,7 @@ namespace Emby.Server.Implementations.Data //} db.ExecuteAll(string.Join(";", queries)); - + return db; } @@ -119,5 +119,27 @@ namespace Emby.Server.Implementations.Data { } + + protected void AddColumn(IDatabaseConnection connection, string table, string columnName, string type) + { + foreach (var row in connection.Query("PRAGMA table_info(" + table + ")")) + { + if (row[1].SQLiteType != SQLiteType.Null) + { + var name = row[1].ToString(); + + if (string.Equals(name, columnName, StringComparison.OrdinalIgnoreCase)) + { + return; + } + } + } + + connection.ExecuteAll(string.Join(";", new string[] + { + "alter table " + table, + "add column " + columnName + " " + type + " NULL" + })); + } } } |
