about summary refs log tree commit diff
path: root/gn_auth/migrations/auth/20221219_03_PcTrb-create-authorisation-code-table.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2026-05-21 13:32:56 -0500
committerFrederick Muriuki Muriithi2026-05-21 13:32:56 -0500
commit6568edd6bf616a0c17c5226f40b494a6b2967dad (patch)
treeccb986a3cec72061f490a15a154b299e12a13101 /gn_auth/migrations/auth/20221219_03_PcTrb-create-authorisation-code-table.py
parentdaf8d4ec95bb5d4a7e0c108c023f64d6954d70df (diff)
downloadgn-auth-6568edd6bf616a0c17c5226f40b494a6b2967dad.tar.gz
Move migrations to top-level gn_auth package.
In preparation for migrating to pyproject.toml (from setup.py and
friends) we need to have only one top-level package. This will also
help in improving testing and checks down the line, since everything
will be relative to one single top-level directory.
Diffstat (limited to 'gn_auth/migrations/auth/20221219_03_PcTrb-create-authorisation-code-table.py')
-rw-r--r--gn_auth/migrations/auth/20221219_03_PcTrb-create-authorisation-code-table.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/gn_auth/migrations/auth/20221219_03_PcTrb-create-authorisation-code-table.py b/gn_auth/migrations/auth/20221219_03_PcTrb-create-authorisation-code-table.py
new file mode 100644
index 0000000..1683f87
--- /dev/null
+++ b/gn_auth/migrations/auth/20221219_03_PcTrb-create-authorisation-code-table.py
@@ -0,0 +1,31 @@
+"""
+create authorisation_code table
+"""
+
+from yoyo import step
+
+__depends__ = {'20221219_02_buSEU-create-oauth2-tokens-table'}
+
+steps = [
+    step(
+        """
+        CREATE TABLE authorisation_code (
+            code_id TEXT NOT NULL,
+            code TEXT UNIQUE NOT NULL,
+            client_id NOT NULL,
+            redirect_uri TEXT,
+            scope TEXT,
+            nonce TEXT,
+            auth_time INTEGER NOT NULL,
+            code_challenge TEXT,
+            code_challenge_method TEXT,
+            user_id TEXT NOT NULL,
+            PRIMARY KEY (code_id),
+            FOREIGN KEY (client_id) REFERENCES oauth2_clients(client_id)
+              ON UPDATE CASCADE ON DELETE RESTRICT,
+            FOREIGN KEY (user_id) REFERENCES users(user_id)
+              ON UPDATE CASCADE ON DELETE RESTRICT
+        ) WITHOUT ROWID
+        """,
+        "DROP TABLE IF EXISTS authorisation_code")
+]