protected virtual void Generate(NpgsqlCreateDatabaseOperation operation, [CanBeNull] IModel model, MigrationCommandListBuilder builder) { Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); builder .Append("CREATE DATABASE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name)); if (operation.Template != null) { builder .Append(" TEMPLATE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Template)); } if (operation.Tablespace != null) { builder .Append(" TABLESPACE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Tablespace)); } builder.AppendLine(';'); EndStatement(builder, suppressTransaction: true); }
protected override void Generate(NpgsqlCreateDatabaseOperation operation, IModel model, MigrationCommandListBuilder builder) { builder .Append("CREATE DATABASE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name)); // POSTGRES gotcha: Indexed Text column (even if PK) are not used if we are not using C locale builder .Append(" TEMPLATE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier("template0")); builder .Append(" LC_CTYPE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier("C")); builder .Append(" LC_COLLATE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier("C")); builder .Append(" ENCODING ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier("UTF8")); if (operation.Tablespace != null) { builder .Append(" TABLESPACE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Tablespace)); } builder.AppendLine(Dependencies.SqlGenerationHelper.StatementTerminator); EndStatement(builder, suppressTransaction: true); }
public virtual void Generate(NpgsqlCreateDatabaseOperation operation, IModel model, RelationalCommandListBuilder builder) { Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); builder .Append("CREATE DATABASE ") .Append(SqlGenerationHelper.DelimitIdentifier(operation.Name)); if (operation.Template != null) { builder .Append(" TEMPLATE ") .Append(SqlGenerationHelper.DelimitIdentifier(operation.Template)); } }
// based on: https://github.com/npgsql/efcore.pg/blob/v3.1.4/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs#L731 protected override void Generate(NpgsqlCreateDatabaseOperation operation, IModel?model, MigrationCommandListBuilder builder) { if (operation == null) { throw new ArgumentNullException(nameof(operation)); } if (builder == null) { throw new ArgumentNullException(nameof(builder)); } builder .Append("CREATE DATABASE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name)); if (operation.Template != null) { builder .Append(" TEMPLATE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Template)); } if (operation.Tablespace != null) { builder .Append(" TABLESPACE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Tablespace)); } builder .Append(" ENCODING ") .Append('\'').Append(_dbEncoding).Append('\''); builder .Append(" LC_COLLATE ") .Append('\'').Append(_dbCollation).Append('\''); builder .Append(" LC_CTYPE ") .Append('\'').Append(_dbCollation).Append('\''); builder.AppendLine(';'); EndStatement(builder, suppressTransaction: true); }
public virtual void Generate(NpgsqlCreateDatabaseOperation operation, [CanBeNull] IModel model, MigrationCommandListBuilder builder) { Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); builder .Append("CREATE DATABASE ") .Append(SqlGenerationHelper.DelimitIdentifier(operation.Name)); if (operation.Template != null) { builder .Append(" TEMPLATE ") .Append(SqlGenerationHelper.DelimitIdentifier(operation.Template)); } builder.AppendLine(SqlGenerationHelper.StatementTerminator); EndStatement(builder, suppressTransaction: true); }