PlanTempusApp/Database/NavigationSystem/Setup.cs

51 lines
1.4 KiB
C#
Raw Normal View History

2025-02-06 16:58:13 +01:00
using Insight.Database;
using System.Data;
2025-02-06 23:46:55 +01:00
namespace Database.NavigationSystem
2025-02-06 16:58:13 +01:00
{
2025-02-06 23:46:55 +01:00
internal class Setup
2025-02-06 16:58:13 +01:00
{
private readonly IDbConnection _db;
2025-02-06 23:46:55 +01:00
public Setup(IDbConnection db)
2025-02-06 16:58:13 +01:00
{
_db = db;
}
2025-02-06 23:46:55 +01:00
public void CreateSystem()
{
2025-02-11 17:07:01 +01:00
//await CreateNavigationLinkTemplatesTable(schema);
//await CreateNavigationLinkTemplateTranslationsTable(schema);
}
2025-02-06 16:58:13 +01:00
2025-02-11 17:07:01 +01:00
private async Task CreateNavigationLinkTemplatesTable()
2025-02-06 16:58:13 +01:00
{
var sql = $@"
2025-02-11 17:07:01 +01:00
CREATE TABLE IF NOT EXISTS navigation_link_templates (
2025-02-06 16:58:13 +01:00
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,
2025-02-11 17:07:01 +01:00
FOREIGN KEY (permission_id) REFERENCES permissions(id),
FOREIGN KEY (parent_id) REFERENCES navigation_link_templates(id)
2025-02-06 16:58:13 +01:00
)";
await _db.ExecuteAsync(sql);
}
private async Task CreateNavigationLinkTemplateTranslationsTable(string schema)
{
var sql = $@"
2025-02-11 17:07:01 +01:00
CREATE TABLE IF NOT EXISTS navigation_link_template_translations (
2025-02-06 16:58:13 +01:00
id SERIAL PRIMARY KEY,
template_id INTEGER NOT NULL,
language VARCHAR(10) NOT NULL,
display_name VARCHAR(100) NOT NULL,
2025-02-11 17:07:01 +01:00
FOREIGN KEY (template_id) REFERENCES navigation_link_templates(id)
2025-02-06 16:58:13 +01:00
)";
await _db.ExecuteAsync(sql);
}
}
}