Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
DB Operation: Open connection
Info: Beginning database upgrade
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Execute scalar command:
select case
when pg_catalog.to_regclass('"schemaversions"') is not null then 1
else 0
end;
DB Operation: Dispose command
Info: Journal table does not exist
Info: Executing Database Server script 'Script0001.sql'
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Execute scalar command:
select case
when pg_catalog.to_regclass('"schemaversions"') is not null then 1
else 0
end;
DB Operation: Dispose command
Info: Creating the "schemaversions" table
DB Operation: Execute non query command: CREATE TABLE "schemaversions"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
DB Operation: Open connection
Info: Beginning database upgrade
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'TestSchemaVersions' and TABLE_SCHEMA = 'test'
DB Operation: Execute scalar command:
select case
when pg_catalog.to_regclass('"test"."TestSchemaVersions"') is not null then 1
else 0
end;
DB Operation: Dispose command
Info: Journal table does not exist
Info: Executing Database Server script 'Script0001.sql'
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'TestSchemaVersions' and TABLE_SCHEMA = 'test'
DB Operation: Execute scalar command:
select case
when pg_catalog.to_regclass('"test"."TestSchemaVersions"') is not null then 1
else 0
end;
DB Operation: Dispose command
Info: Creating the "test"."TestSchemaVersions" table
DB Operation: Execute non query command: CREATE TABLE "test"."TestSchemaVersions"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
DB Operation: Open connection
Info: Beginning database upgrade
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Execute scalar command:
select case
when pg_catalog.to_regclass('"schemaversions"') is not null then 1
else 0
end;
DB Operation: Dispose command
Info: Journal table does not exist
Info: Executing Database Server script 'Script0001.sql'
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Execute scalar command:
select case
when pg_catalog.to_regclass('"schemaversions"') is not null then 1
else 0
end;
DB Operation: Dispose command
Info: Creating the "schemaversions" table
DB Operation: Execute non query command: CREATE TABLE "schemaversions"
Expand Down
1 change: 1 addition & 0 deletions src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class PostgresqlTableJournal : DbUp.Support.TableJournal
{
public PostgresqlTableJournal(System.Func<DbUp.Engine.Transactions.IConnectionManager> connectionManager, System.Func<DbUp.Engine.Output.IUpgradeLog> logger, string schema, string tableName) { }
protected override string CreateSchemaTableSql(string quotedPrimaryKeyName) { }
protected override string DoesTableExistSql() { }
protected override string GetInsertJournalEntrySql(string scriptName, string applied) { }
protected override System.Data.IDbCommand GetInsertScriptCommand(System.Func<System.Data.IDbCommand> dbCommandFactory, DbUp.Engine.SqlScript script) { }
protected override string GetJournalEntriesSql() { }
Expand Down
18 changes: 16 additions & 2 deletions src/dbup-postgresql/PostgresqlTableJournal.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Data;
using DbUp.Engine;
using DbUp.Engine.Output;
Expand Down Expand Up @@ -74,4 +74,18 @@ scriptname character varying(255) NOT NULL,
CONSTRAINT {quotedPrimaryKeyName} PRIMARY KEY (schemaversionsid)
)";
}
}

/// <inheritdoc/>
protected override string DoesTableExistSql()
{
string fqSchemaTableName = FqSchemaTableName.Replace("'", "''");

string sql = $@"
select case
when pg_catalog.to_regclass('{fqSchemaTableName}') is not null then 1
else 0
end;";

return sql;
}
}