auth

Main authentication module for my projects
git clone git://git.finwo.net/app/auth
Log | Files | Refs

004_client_mapping.sql (807B)


      1 CREATE TABLE client_realms (
      2   client_id TEXT PRIMARY KEY,
      3   realm_id TEXT REFERENCES realms(id) ON DELETE CASCADE,
      4   created_at INTEGER NOT NULL
      5 );
      6 
      7 CREATE INDEX client_realms_realm ON client_realms(realm_id);
      8 
      9 INSERT INTO client_realms (client_id, realm_id, created_at)
     10 SELECT client_id, realm_id, created_at
     11   FROM oidc_client_hosts;
     12 
     13 CREATE TABLE oidc_client_hosts_new (
     14   host TEXT PRIMARY KEY,
     15   client_id TEXT NOT NULL REFERENCES client_realms(client_id) ON DELETE CASCADE,
     16   created_at INTEGER NOT NULL
     17 );
     18 
     19 INSERT INTO oidc_client_hosts_new (host, client_id, created_at)
     20 SELECT host, client_id, created_at
     21   FROM oidc_client_hosts;
     22 
     23 DROP TABLE oidc_client_hosts;
     24 
     25 ALTER TABLE oidc_client_hosts_new RENAME TO oidc_client_hosts;
     26 
     27 CREATE INDEX oidc_client_hosts_client ON oidc_client_hosts(client_id);