protected override void Generate(CreateTableOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true) { base.Generate(operation, model, builder, false); var engineAnnotation = operation.FindAnnotation(ClickHouseAnnotationNames.Engine); var engine = engineAnnotation != null && engineAnnotation.Value != null ? (ClickHouseEngine)engineAnnotation.Value : new StripeLogEngine(); engine.SpecifyEngine(builder, model); builder.AppendLine(Dependencies.SqlGenerationHelper.StatementTerminator); EndStatement(builder); }
private void SetTableDescription(CreateTableOperation operation, MigrationCommandListBuilder builder) { Console.WriteLine("\tHandling [TableDescription]"); var annotation = operation.FindAnnotation("TableDescription"); if (annotation != null) { string schemaName = Utilities.GetSchema(operation.Name); string tableName = Utilities.GetTableName(operation.Name); string description = ((string)annotation.Value).Replace("'", "''"); string sql = $"sp_AddExtendedProperty @name = N'MS_Description'," + $"@value=N'{description}'," + $"@level0type=N'SCHEMA',@level0name=N'{schemaName}'," + $"@level1type=N'TABLE',@level1name=N'{tableName}'"; builder.Append(sql); } }
protected override void Generate(CreateTableOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true) { base.Generate(operation, model, builder, false); var engine = operation.FindAnnotation(ClickHouseAnnotationNames.Engine); if (engine?.Value == null) { throw new InvalidOperationException("Specify engine in table configuration."); } if (engine.Value is string engineValue) { builder.AppendLine("ENGINE = " + engineValue); } else { throw new NotImplementedException(); } }