authelia/internal/storage/migrations/V0005.ConsentSubjectNULL.postgres.up.sql
James Elliott 555746e771
refactor: exclude id from sqlite3 migration (#3242)
* refactor: exclude id from sqlite3 table recreate

* docs: add migration docs
2022-04-25 21:11:56 +10:00

7 lines
590 B
SQL

DELETE FROM oauth2_consent_session WHERE subject IN(SELECT identifier FROM user_opaque_identifier WHERE username = '' AND service IN('openid', 'openid_connect'));
DELETE FROM user_opaque_identifier WHERE username = '' AND service IN('openid', 'openid_connect');
DELETE FROM user_opaque_identifier WHERE service <> 'openid';
ALTER TABLE oauth2_consent_session ALTER COLUMN subject DROP NOT NULL;
ALTER TABLE oauth2_consent_session ALTER COLUMN subject SET DEFAULT NULL;
ALTER TABLE oauth2_consent_session RENAME CONSTRAINT oauth2_consent_subject_fkey TO oauth2_consent_session_subject_fkey;