02ddbbff29a7_naming_conventions.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. """naming_conventions
  2. Revision ID: 02ddbbff29a7
  3. Revises: b797328ac32d
  4. Create Date: 2020-09-17 11:05:37.195404
  5. """
  6. from alembic import op
  7. # revision identifiers, used by Alembic.
  8. revision = "02ddbbff29a7"
  9. down_revision = "b797328ac32d"
  10. branch_labels = None
  11. depends_on = None
  12. def upgrade():
  13. op.create_unique_constraint(
  14. op.f("weather_sensor_type_name_latitude_longitude_key"),
  15. "weather_sensor",
  16. ["weather_sensor_type_name", "latitude", "longitude"],
  17. )
  18. op.drop_constraint(op.f("_type_name_location_unique"), table_name="weather_sensor")
  19. # ### commands auto generated by Alembic - please adjust! ###
  20. op.create_index(
  21. op.f("asset_type_can_curtail_idx"), "asset_type", ["can_curtail"], unique=False
  22. )
  23. op.create_index(
  24. op.f("asset_type_can_shift_idx"), "asset_type", ["can_shift"], unique=False
  25. )
  26. op.drop_index("ix_asset_type_can_curtail", table_name="asset_type")
  27. op.drop_index("ix_asset_type_can_shift", table_name="asset_type")
  28. # ### end Alembic commands ###
  29. def downgrade():
  30. op.drop_constraint(
  31. op.f("weather_sensor_type_name_latitude_longitude_key"),
  32. table_name="weather_sensor",
  33. )
  34. op.create_unique_constraint(
  35. op.f("_type_name_location_unique"),
  36. "weather_sensor",
  37. ["weather_sensor_type_name", "latitude", "longitude"],
  38. )
  39. # ### commands auto generated by Alembic - please adjust! ###
  40. op.create_index(
  41. "ix_asset_type_can_shift", "asset_type", ["can_shift"], unique=False
  42. )
  43. op.create_index(
  44. "ix_asset_type_can_curtail", "asset_type", ["can_curtail"], unique=False
  45. )
  46. op.drop_index(op.f("asset_type_can_shift_idx"), table_name="asset_type")
  47. op.drop_index(op.f("asset_type_can_curtail_idx"), table_name="asset_type")
  48. # ### end Alembic commands ###