protected override void Generate(EnsureSchemaOperation operation, IModel model, RelationalCommandListBuilder builder) { }
protected override void Generate(EnsureSchemaOperation operation, IModel model, MigrationCommandListBuilder builder) { throw new NotSupportedException(SqliteStrings.SchemasNotSupported); }
protected override void Generate(EnsureSchemaOperation operation, IModel model, MigrationCommandListBuilder builder) { Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); builder .AppendLine($"CREATE OR REPLACE FUNCTION MyCat_ef_ensure_schema() RETURNS VOID") .AppendLine($"BEGIN") .AppendLine($" IF NOT EXISTS(SELECT 1 FROM `information_schema`.`SCHEMATA` where `SCHEMA_NAME` = '{ operation.Name }')") .AppendLine($" THEN") .AppendLine($" CREATE SCHEMA { operation.Name };") .AppendLine($" END IF;") .AppendLine($"END") .AppendLine(SqlGenerationHelper.BatchTerminator); }
protected override void Generate(EnsureSchemaOperation operation, IModel model, MigrationCommandListBuilder builder) { Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); if (string.Equals(operation.Name, "DBO", StringComparison.OrdinalIgnoreCase)) { return; } builder .Append("IF SCHEMA_ID(") .Append(SqlGenerationHelper.GenerateLiteral(operation.Name)) .Append(") IS NULL EXEC(N'CREATE SCHEMA ") .Append(SqlGenerationHelper.DelimitIdentifier(operation.Name)) .Append("')") .AppendLine(SqlGenerationHelper.StatementTerminator); EndStatement(builder); }