aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--migrations/auth/20221208_01_sSdHz-add-public-column-to-resources-table.py16
-rw-r--r--tests/unit/auth/test_migrations_add_remove_columns.py4
2 files changed, 19 insertions, 1 deletions
diff --git a/migrations/auth/20221208_01_sSdHz-add-public-column-to-resources-table.py b/migrations/auth/20221208_01_sSdHz-add-public-column-to-resources-table.py
new file mode 100644
index 0000000..2238069
--- /dev/null
+++ b/migrations/auth/20221208_01_sSdHz-add-public-column-to-resources-table.py
@@ -0,0 +1,16 @@
+"""
+Add 'public' column to 'resources' table
+"""
+
+from yoyo import step
+
+__depends__ = {'20221206_01_BbeF9-create-group-user-roles-on-resources-table'}
+
+steps = [
+ step(
+ """
+ ALTER TABLE resources ADD COLUMN
+ public INTEGER NOT NULL DEFAULT 0 CHECK (public=0 or public=1)
+ """,
+ "ALTER TABLE resources DROP COLUMN public")
+]
diff --git a/tests/unit/auth/test_migrations_add_remove_columns.py b/tests/unit/auth/test_migrations_add_remove_columns.py
index d149c64..ea9bf7b 100644
--- a/tests/unit/auth/test_migrations_add_remove_columns.py
+++ b/tests/unit/auth/test_migrations_add_remove_columns.py
@@ -18,7 +18,9 @@ TEST_PARAMS = (
"columns-to-privileges-table.py"),
"privileges", "privilege_description TEXT", True),
("20221117_01_RDlfx-modify-group-roles-add-group-role-id.py", "group_roles",
- "group_role_id", True))
+ "group_role_id", True),
+ ("20221208_01_sSdHz-add-public-column-to-resources-table.py", "resources",
+ "public", True))
def found(haystack: str, needle: str) -> bool:
"""Check whether `needle` is found in `haystack`"""