public async Task CreateTable(ITable table)
 {
     if (await _db.TableExists(table.GetTableName()))
     {
         return;
     }
     await _db.CreateTable(table.GetTableScheme());
 }
 private void CreateMigrationTableIfNotExists()
 {
     _dbProvider.CreateTable(new Table
     {
         Name    = MigrationsTableName,
         Engine  = "TinyLog",
         Columns = new List <Column>
         {
             new Column("applied_at", "DateTime", "DEFAULT now()"),
             new Column("name", "String")
         }
     });
 }
Пример #3
0
        public static bool CastRawValuesToClassTypeProperties(IClickHouseDatabase db)
        {
            if (db.TableExists("Test"))
            {
                db.DropTable("Test");
            }

            db.CreateTable(new Table
            {
                Engine  = "MergeTree(date, (date, Id, Number, Cost), 8192)",
                Name    = "Test",
                Columns = new List <Column>()
                {
                    new Column("date", "Date"),
                    new Column("Id", "String"),
                    new Column("Number", "Int32"),
                    new Column("Cost", "Float64"),
                    new Column("Name", "String"),
                    new Column("Ushort", "UInt16"),
                    new Column("Uint", "UInt32"),
                }
            });

            var testItem = new TestDataItem3
            {
                Id     = Guid.NewGuid(),
                Number = -96,
                Cost   = 31,
                Name   = "Jon Skeet",
                Ushort = 150,
                Uint   = 65536
            };

            var command = testItem.GetInsertCommand();

            db.ExecuteNonQuery(command);

            command = "SELECT Id, Number, Cost, Name, Ushort, Uint FROM Test";
            var resultItem = db.ExecuteQueryMapping <TestDataItem3>(command, convention: new UnderscoreNamingConvention()).Single();

            db.DropTable("Test");
            return(testItem.Equals(resultItem));
        }