Setup db automation
This commit is contained in:
parent
1540f9f655
commit
72544d62e2
12 changed files with 473 additions and 337 deletions
49
Database/RolesPermissionSystem/NavigationSystem.cs
Normal file
49
Database/RolesPermissionSystem/NavigationSystem.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using Insight.Database;
|
||||
using System.Data;
|
||||
|
||||
namespace Database.RolesPermissionSystem
|
||||
{
|
||||
internal class NavigationSystem
|
||||
{
|
||||
|
||||
private readonly IDbConnection _db;
|
||||
|
||||
public NavigationSystem(IDbConnection db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
|
||||
|
||||
private async Task CreateNavigationLinkTemplatesTable(string schema)
|
||||
{
|
||||
var sql = $@"
|
||||
CREATE TABLE IF NOT EXISTS {schema}.navigation_link_templates (
|
||||
id SERIAL PRIMARY KEY,
|
||||
parent_id INTEGER NULL,
|
||||
url VARCHAR(500) NOT NULL,
|
||||
permission_id INTEGER NULL,
|
||||
icon VARCHAR(100) NULL,
|
||||
default_order INTEGER NOT NULL,
|
||||
FOREIGN KEY (permission_id) REFERENCES {schema}.permissions(id),
|
||||
FOREIGN KEY (parent_id) REFERENCES {schema}.navigation_link_templates(id)
|
||||
)";
|
||||
await _db.ExecuteAsync(sql);
|
||||
}
|
||||
|
||||
private async Task CreateNavigationLinkTemplateTranslationsTable(string schema)
|
||||
{
|
||||
var sql = $@"
|
||||
CREATE TABLE IF NOT EXISTS {schema}.navigation_link_template_translations (
|
||||
id SERIAL PRIMARY KEY,
|
||||
template_id INTEGER NOT NULL,
|
||||
language VARCHAR(10) NOT NULL,
|
||||
display_name VARCHAR(100) NOT NULL,
|
||||
FOREIGN KEY (template_id) REFERENCES {schema}.navigation_link_templates(id)
|
||||
)";
|
||||
await _db.ExecuteAsync(sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue