-- oauth_clients
ALTERTABLEoauth_clientsRENAMETOoauth_clients_old;CREATETABLEIFNOTEXISTSoauth_clients(client_idTEXTPRIMARYKEY,client_secret_hashTEXT,redirect_urisJSONNOTNULLDEFAULT'[]',allowed_scopesJSONNOTNULLDEFAULT'[]',client_nameTEXT,client_uriURL,logo_uriURL,contactsJSON,token_endpoint_auth_methodTEXTDEFAULT'client_secret_basic',grant_typesJSONDEFAULT'["authorization_code"]',response_typesJSONDEFAULT'["code"]',registration_access_token_hashTEXT,created_atTIMESTAMPDEFAULT(strftime('%Y-%m-%dT%H:%M:%SZ','now')));INSERTINTOoauth_clientsSELECT*FROMoauth_clients_old;DROPTABLEoauth_clients_old;-- push_login_requests
ALTERTABLEpush_login_requestsRENAMETOpush_login_requests_old;CREATETABLEIFNOTEXISTSpush_login_requests(tokenTEXTPRIMARYKEY,meURLNOTNULL,statusTEXTNOTNULLDEFAULT'pending',next_urlTEXT,created_atTIMESTAMPDEFAULT(strftime('%Y-%m-%dT%H:%M:%SZ','now')),expires_atTIMESTAMPNOTNULL);INSERTINTOpush_login_requestsSELECT*FROMpush_login_requests_old;DROPTABLEpush_login_requests_old;-- oauth_authorization_codes
ALTERTABLEoauth_authorization_codesRENAMETOoauth_authorization_codes_old;CREATETABLEIFNOTEXISTSoauth_authorization_codes(codeTEXTPRIMARYKEY,client_idTEXTNOTNULL,meURLNOTNULL,redirect_uriURLNOTNULL,response_typeTEXTNOTNULL,scopeTEXTNOTNULL,resourceTEXT,code_challengeTEXT,code_challenge_methodTEXT,nonceTEXT,access_token_expires_inINTEGER,usedBOOLEANDEFAULTFALSE,expires_atTIMESTAMPNOTNULL,revokedBOOLEANDEFAULTFALSE,created_atTIMESTAMPDEFAULT(strftime('%Y-%m-%dT%H:%M:%SZ','now')));INSERTINTOoauth_authorization_codesSELECT*FROMoauth_authorization_codes_old;DROPTABLEoauth_authorization_codes_old;
```sql
-- oauth_clients
ALTER TABLE oauth_clients RENAME TO oauth_clients_old;
CREATE TABLE IF NOT EXISTS oauth_clients (
client_id TEXT PRIMARY KEY,
client_secret_hash TEXT,
redirect_uris JSON NOT NULL DEFAULT '[]',
allowed_scopes JSON NOT NULL DEFAULT '[]',
client_name TEXT,
client_uri URL,
logo_uri URL,
contacts JSON,
token_endpoint_auth_method TEXT DEFAULT 'client_secret_basic',
grant_types JSON DEFAULT '["authorization_code"]',
response_types JSON DEFAULT '["code"]',
registration_access_token_hash TEXT,
created_at TIMESTAMP DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now'))
);
INSERT INTO oauth_clients SELECT * FROM oauth_clients_old;
DROP TABLE oauth_clients_old;
-- push_login_requests
ALTER TABLE push_login_requests RENAME TO push_login_requests_old;
CREATE TABLE IF NOT EXISTS push_login_requests (
token TEXT PRIMARY KEY,
me URL NOT NULL,
status TEXT NOT NULL DEFAULT 'pending',
next_url TEXT,
created_at TIMESTAMP DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
expires_at TIMESTAMP NOT NULL
);
INSERT INTO push_login_requests SELECT * FROM push_login_requests_old;
DROP TABLE push_login_requests_old;
-- oauth_authorization_codes
ALTER TABLE oauth_authorization_codes RENAME TO oauth_authorization_codes_old;
CREATE TABLE IF NOT EXISTS oauth_authorization_codes (
code TEXT PRIMARY KEY,
client_id TEXT NOT NULL,
me URL NOT NULL,
redirect_uri URL NOT NULL,
response_type TEXT NOT NULL,
scope TEXT NOT NULL,
resource TEXT,
code_challenge TEXT,
code_challenge_method TEXT,
nonce TEXT,
access_token_expires_in INTEGER,
used BOOLEAN DEFAULT FALSE,
expires_at TIMESTAMP NOT NULL,
revoked BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now'))
);
INSERT INTO oauth_authorization_codes SELECT * FROM oauth_authorization_codes_old;
DROP TABLE oauth_authorization_codes_old;
```