forked from siteserver/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginDatabaseTableManager.cs
More file actions
28 lines (25 loc) · 955 Bytes
/
PluginDatabaseTableManager.cs
File metadata and controls
28 lines (25 loc) · 955 Bytes
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
using SiteServer.CMS.Core;
using SiteServer.CMS.Plugin.Model;
namespace SiteServer.CMS.Plugin
{
public class PluginDatabaseTableManager
{
public static void SyncTable(PluginService service)
{
if (service.DatabaseTables == null || service.DatabaseTables.Count <= 0) return;
foreach (var tableName in service.DatabaseTables.Keys)
{
var tableColumns = service.DatabaseTables[tableName];
if (tableColumns == null || tableColumns.Count == 0) continue;
if (!DataProvider.DatabaseDao.IsTableExists(tableName))
{
DataProvider.DatabaseDao.CreatePluginTable(service.PluginId, tableName, tableColumns);
}
else
{
DataProvider.DatabaseDao.AlterPluginTable(service.PluginId, tableName, tableColumns);
}
}
}
}
}