Skip to content

Feature/postgres support - #2083

Open
Stephan-Kok wants to merge 8 commits into
mainfrom
feature/postgres_support
Open

Stephan-Kok wants to merge 8 commits into
mainfrom
feature/postgres_support

Conversation

@Stephan-Kok

Copy link
Copy Markdown
Contributor

PostgreSQL support

This PR is a follow-up to [PR #2082](#2082).

In this PR, we remove the sso_provider_roles_eb5 table and introduce PostgreSQL support.

PostgreSQL documentation

I have added a document with additional information about how to use the PostgreSQL database and how the integration works:

https://github.com/OpenConext/OpenConext-engineblock/blob/feature/postgres_support/postgres_support.md

The document also describes some additional changes that are required in the EngineBlock container and OpenConext-devconf to support PostgreSQL natively.

Additionally, I think we should discuss whether we can add a CI/CD test using a PostgreSQL database to ensure that PostgreSQL support continues to work going forward.

Consent

One aspect I would like you to look into more deeply is the Consent functionality.

We currently do not use the Consent feature, but PostgreSQL does not support the SQL value 0000-00-00 00:00:00, which is used in a hardcoded SQL query.

I have attempted to address this by replacing it with the epoch date 1970-01-01 00:00:00. Please see DbalConsentRepository.php in this PR.

During my initial investigation, it appeared that deleted_at may have been incorrectly configured as a primary key, which is the reason this workaround seems to be necessary.

If this is not intentional, it would be preferable to remove this requirement and solve the underlying issue rather than keeping my current workaround. Please take a closer look at this part of the PR and let me know if the deleted_at primary key is intentional.

@Stephan-Kok
Stephan-Kok force-pushed the feature/postgres_support branch from c0e70a3 to ab0cc49 Compare August 24, 2026 11:38
@Stephan-Kok
Stephan-Kok force-pushed the feature/postgres_support branch from 21e994f to 8617431 Compare August 24, 2026 12:24
@Stephan-Kok

Copy link
Copy Markdown
Contributor Author

I have adjusted the CI scripts to contains tests using the native behat tests, but with a postgresql database. I have used the environment 'postgres' for this use case.

@baszoetekouw baszoetekouw added this to the 8.0 milestone Sep 22, 2026

public function up(Schema $schema): void
{
$this->addSql('DROP TABLE sso_provider_roles_eb5');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This drops sso_provider_roles_eb5 outright. I don't see a migration anywhere in either PR that copies existing data from sso_provider_roles_eb5 into sso_provider_roles_eb6 first. Combined with the point raised on #2082 about sso_provider_roles_eb6 starting out empty, can you confirm how existing environments retain their metadata through this transition?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This release can only be done when previous release has been executed on all nodes. That means that all nodes will use EB6 and not EB5. So it can be dropped.

Data will not be migrated from EB5 to EB6 with the sole reason that the database is populated from Manage. Migrating the data is very error prone and will take quite some effort.

I believe we agreed upon this solution in our call right? Please contact me if you want to discuss some more.

{
$conn = $this->connection;

$exists = $conn->fetchOne(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetchOne() returns a scalar value here (the 1 from SELECT 1), not a row object. See the property access below on $exists (->hashedUserId, ->deleted_at), that won't work as written.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find. I have updated the PR with a upsert fix. Please do note that when you fix the primary key on deleted_at that this will no longer work.

'attribute' => $parameters->attributeHash,
'attributeStable' => $parameters->attributeStableHash,
'consentType' => $parameters->consentType,
'hashedUserId' => $exists->hashedUserId,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$exists is a scalar (see fetchOne() above), so $exists->hashedUserId/$exists->serviceId/$exists->deleted_at here would not work as written. Can you double check this path?

Comment thread composer.json
"psr-4": {
"OpenConext\\": "src/OpenConext",
"OpenConext\\EngineBlock\\Doctrine\\Migrations\\": "migrations/DoctrineMigrations"
"OpenConext\\EngineBlock\\Doctrine\\Migrations\\": "migrations/MariaMigrations"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This namespace (OpenConext\EngineBlock\Doctrine\Migrations) is also mapped to migrations/PostgresMigrations in config/packages/postgres/doctrine_migrations.yaml. Just flagging this so we're aware two migrations (one Maria, one Postgres) could end up with the same version number across the two directories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants