aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/db/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/db/migrations')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/e7f8a9b0c1d2_push_subscriptions.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/e7f8a9b0c1d2_push_subscriptions.py b/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/e7f8a9b0c1d2_push_subscriptions.py
new file mode 100644
index 0000000..4311448
--- /dev/null
+++ b/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/e7f8a9b0c1d2_push_subscriptions.py
@@ -0,0 +1,35 @@
+"""phones told about notifications: a Web Push endpoint, or a poll secret
+
+Revision ID: e7f8a9b0c1d2
+Revises: d4e5f6a7b8ca
+"""
+
+from collections.abc import Sequence
+
+import sqlalchemy as sa
+from alembic import op
+
+revision: str = "e7f8a9b0c1d2"
+down_revision: str | Sequence[str] | None = "d4e5f6a7b8ca"
+branch_labels: str | Sequence[str] | None = None
+depends_on: str | Sequence[str] | None = None
+
+
+def upgrade() -> None:
+ op.create_table(
+ "push_subscriptions",
+ sa.Column("id", sa.String(36), primary_key=True),
+ sa.Column("user_id", sa.String(36), sa.ForeignKey("users.id"), nullable=False),
+ sa.Column("endpoint", sa.String(1024), nullable=True),
+ sa.Column("p256dh", sa.String(128), nullable=True),
+ sa.Column("auth", sa.String(32), nullable=True),
+ sa.Column("poll_hash", sa.String(64), nullable=True),
+ sa.Column("created_at", sa.DateTime(timezone=True)),
+ )
+ op.create_index("ix_push_subscriptions_user_endpoint", "push_subscriptions",
+ ["user_id", "endpoint"], unique=True)
+
+
+def downgrade() -> None:
+ op.drop_index("ix_push_subscriptions_user_endpoint", table_name="push_subscriptions")
+ op.drop_table("push_subscriptions")