| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using Dapper;
- using SWRIS.Core;
- using System;
- namespace SWRIS.Migrations
- {
- public class Initial_Migration : SqLiteBaseRepository
- {
- public static DateTime Time { get; } = DateTime.Parse("2025-10-01 08:00:00");
- public static void Excute()
- {
- using (var conn = DbConnection())
- {
- string @string = string.Empty;
- conn.Open();
- @string = @"CREATE TABLE IF NOT EXISTS Migrations (
- MigrationId VARCHAR(150) PRIMARY KEY,
- Time DATETIME NOT NULL,
- ExcuteTime DATETIME NOT NULL
- );";
- conn.Execute(@string.ToString());
- @string = @"CREATE TABLE Records (
- Id INTEGER PRIMARY KEY AUTOINCREMENT,
- RopeNumber INTEGER,
- RopeName TEXT (100),
- StartTime DATETIME NOT NULL,
- EndTime DATETIME NOT NULL,
- StartPoint REAL,
- EndPoint REAL,
- DetectionLength REAL,
- DetectedSpeed REAL,
- DamageCount INTEGER,
- RiskLevel INTEGER,
- DataFilePath TEXT (300),
- SensorCount INTEGER DEFAULT (4) NOT NULL,
- SamplingStep REAL,
- ExportCount INTEGER DEFAULT (0) NOT NULL,
- InUseSensors TEXT (100) DEFAULT ('1,2,3,4')
- );";
- conn.Execute(@string.ToString());
- @string = @"CREATE TABLE Damages (
- Id INTEGER PRIMARY KEY AUTOINCREMENT,
- RecordId INTEGER NOT NULL,
- DamagePoint REAL NOT NULL,
- DamageValue REAL,
- DamageLevel INTEGER
- );";
- conn.Execute(@string.ToString());
- #region Migrations
- @string = (@"INSERT INTO Migrations
- ( MigrationId, Time, ExcuteTime ) VALUES
- ( @MigrationId, @Time, @ExcuteTime );");
- conn.Execute(@string.ToString(), new { MigrationId = "Initial_Migration", Time, ExcuteTime = DateTime.Now });
- #endregion
- }
- }
- }
- }
|