Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: database existence check in HistoryRepository no longer goes through DatabaseCreator #34569

Closed
roji opened this issue Aug 29, 2024 · 0 comments
Labels
area-migrations closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported regression type-bug type-enhancement
Milestone

Comments

@roji
Copy link
Member

roji commented Aug 29, 2024

As part of #34115, the implementation of HistoryRepository.Exists was changed to no longer use the DatabaseCreator:

Old Exists

public virtual bool Exists()
	=> Dependencies.DatabaseCreator.Exists()
		&& InterpretExistsResult(
			Dependencies.RawSqlCommandBuilder.Build(ExistsSql).ExecuteScalar(
				new RelationalCommandParameterObject(
					Dependencies.Connection,
					null,
					null,
					Dependencies.CurrentContext.Context,
					Dependencies.CommandLogger, CommandSource.Migrations)));

New Exists

public virtual bool Exists()
	=> InterpretExistsResult(
		Dependencies.RawSqlCommandBuilder.Build(ExistsSql).ExecuteScalar(
			new RelationalCommandParameterObject(
				Dependencies.Connection,
				null,
				null,
				Dependencies.CurrentContext.Context,
				Dependencies.CommandLogger, CommandSource.Migrations)));

This breaks PG, and likely other databases as well - it assumes that one can connect/login with the connection string containing the non-existing database, and then find out whether the database exists via the query. But in PG you can't connect to a non-existing database.

As a result, NpgsqlDatabaseCreator implements its Exists by simply trying to connect, and interpreting "database doesn't exist" behavior to return false etc.

@roji roji added this to the 9.0.0 milestone Aug 29, 2024
@AndriySvyryd AndriySvyryd added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Aug 29, 2024
@AndriySvyryd AndriySvyryd removed their assignment Aug 29, 2024
AndriySvyryd added a commit that referenced this issue Aug 29, 2024
AndriySvyryd added a commit that referenced this issue Aug 30, 2024
AndriySvyryd added a commit that referenced this issue Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migrations closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported regression type-bug type-enhancement
Projects
None yet
Development

No branches or pull requests

2 participants