forked from graze-social/aip
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path020_remove_did_from_oauth_requests.sql
More file actions
69 lines (55 loc) · 1.82 KB
/
Copy path020_remove_did_from_oauth_requests.sql
File metadata and controls
69 lines (55 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- Migration: Remove did column from oauth_requests table
-- This removes the did column which was previously made nullable but is no longer needed
-- SQLite doesn't support ALTER TABLE DROP COLUMN directly, so we need to recreate the table
-- Step 1: Create new table without did column
CREATE TABLE oauth_requests_new (
-- OAuth state parameter as primary key
oauth_state TEXT PRIMARY KEY,
-- Issuer URL
issuer TEXT NOT NULL,
-- Authorization server endpoint
authorization_server TEXT NOT NULL,
-- Nonce for security
nonce TEXT NOT NULL,
-- PKCE verifier
pkce_verifier TEXT NOT NULL,
-- Signing public key
signing_public_key TEXT NOT NULL,
-- DPoP private key
dpop_private_key TEXT NOT NULL,
-- Creation timestamp (ISO 8601 format)
created_at TEXT NOT NULL,
-- Expiration timestamp (ISO 8601 format)
expires_at TEXT NOT NULL
);
-- Step 2: Copy data from old table to new table, excluding the did column
INSERT INTO oauth_requests_new (
oauth_state,
issuer,
authorization_server,
nonce,
pkce_verifier,
signing_public_key,
dpop_private_key,
created_at,
expires_at
)
SELECT
oauth_state,
issuer,
authorization_server,
nonce,
pkce_verifier,
signing_public_key,
dpop_private_key,
created_at,
expires_at
FROM oauth_requests;
-- Step 3: Drop old table
DROP TABLE oauth_requests;
-- Step 4: Rename new table to original name
ALTER TABLE oauth_requests_new RENAME TO oauth_requests;
-- Step 5: Recreate indexes (excluding did-related ones)
CREATE INDEX idx_oauth_requests_expires_at ON oauth_requests(expires_at);
CREATE INDEX idx_oauth_requests_created_at ON oauth_requests(created_at);
CREATE INDEX idx_oauth_requests_authorization_server ON oauth_requests(authorization_server);