Something something like soundcloud but not like soundcloud.
Log in, upload records, done.
Simple, easy, KISS.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28_2e83f405e9a4_.py 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. """Add Activity and Follower
  2. Revision ID: 2e83f405e9a4
  3. Revises: 687d40646d63
  4. Create Date: 2018-08-06 16:42:14.355373
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = "2e83f405e9a4"
  8. down_revision = "687d40646d63"
  9. from alembic import op # noqa: E402
  10. import sqlalchemy as sa # noqa: E402
  11. from sqlalchemy.dialects import postgresql # noqa: E402
  12. import sqlalchemy_utils # noqa: E402
  13. def upgrade():
  14. op.create_table(
  15. "activity",
  16. sa.Column("id", sa.Integer(), nullable=False),
  17. sa.Column("actor", sa.Integer(), nullable=True),
  18. sa.Column("uuid", postgresql.UUID(as_uuid=True), server_default=sa.text("uuid_generate_v4()"), nullable=True),
  19. sa.Column("url", sqlalchemy_utils.types.url.URLType(), nullable=True),
  20. sa.Column("type", sa.String(length=100), nullable=True),
  21. sa.Column("payload", sqlalchemy_utils.types.json.JSONType(), nullable=True),
  22. sa.Column("creation_date", sa.DateTime(), nullable=True),
  23. sa.Column("delivered", sa.Boolean(), nullable=True),
  24. sa.Column("delivered_date", sa.DateTime(), nullable=True),
  25. sa.ForeignKeyConstraint(["actor"], ["actor.id"]),
  26. sa.PrimaryKeyConstraint("id"),
  27. sa.UniqueConstraint("url"),
  28. sa.UniqueConstraint("uuid"),
  29. )
  30. op.create_index(op.f("ix_activity_type"), "activity", ["type"], unique=False)
  31. op.create_table(
  32. "followers",
  33. sa.Column("id", sa.Integer(), nullable=False),
  34. sa.Column("uuid", postgresql.UUID(as_uuid=True), server_default=sa.text("uuid_generate_v4()"), nullable=True),
  35. sa.Column("actor_id", sa.Integer(), nullable=True),
  36. sa.Column("target_id", sa.Integer(), nullable=True),
  37. sa.Column("creation_date", sa.DateTime(), nullable=True),
  38. sa.Column("modification_date", sa.DateTime(), nullable=True),
  39. sa.ForeignKeyConstraint(["actor_id"], ["actor.id"]),
  40. sa.ForeignKeyConstraint(["target_id"], ["actor.id"]),
  41. sa.PrimaryKeyConstraint("id"),
  42. sa.UniqueConstraint("actor_id", "target_id", name="unique_following"),
  43. sa.UniqueConstraint("uuid"),
  44. )
  45. op.drop_table("follow")
  46. def downgrade():
  47. op.create_table(
  48. "follow",
  49. sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
  50. sa.Column(
  51. "uuid", postgresql.UUID(), server_default=sa.text("uuid_generate_v4()"), autoincrement=False, nullable=True
  52. ),
  53. sa.Column("creation_date", postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
  54. sa.Column("modification_date", postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
  55. sa.PrimaryKeyConstraint("id", name="follow_pkey"),
  56. sa.UniqueConstraint("uuid", name="follow_uuid_key"),
  57. )
  58. op.drop_table("followers")
  59. op.drop_index(op.f("ix_activity_type"), table_name="activity")
  60. op.drop_table("activity")