Project

General

Profile

Task #6096 » 0001-Add-Alembic-revision-to-enable-CLUSTER-on-Hawat-tabl.patch

Radko Krkoš, 01/14/2020 10:47 AM

View differences:

lib/hawat/migrations/versions/3da0b2119f35_enable_cluster.py
1
"""Enable CLUSTER
2

  
3
Revision ID: 3da0b2119f35
4
Revises: 29c1e46e89c7
5
Create Date: 2020-01-14 09:57:20.597127
6

  
7
"""
8
from alembic import op
9
import sqlalchemy as sa
10

  
11

  
12
# revision identifiers, used by Alembic.
13
revision = '3da0b2119f35'	# pylint: disable=locally-disabled,invalid-name
14
down_revision = '29c1e46e89c7'	# pylint: disable=locally-disabled,invalid-name
15
branch_labels = None		# pylint: disable=locally-disabled,invalid-name
16
depends_on = None		# pylint: disable=locally-disabled,invalid-name
17

  
18

  
19
def upgrade():		# pylint: disable=locally-disabled,missing-docstring
20
    op.execute("ALTER TABLE users CLUSTER ON users_pkey")
21
    op.execute("ALTER TABLE groups CLUSTER ON groups_pkey")
22
    op.execute("ALTER TABLE networks CLUSTER ON networks_pkey")
23
    op.execute("ALTER TABLE filters CLUSTER ON filters_pkey")
24
    op.execute("ALTER TABLE reports_events CLUSTER ON reports_events_pkey")
25
    op.execute("ALTER TABLE statistics_events CLUSTER ON statistics_events_pkey")
26
    op.execute("ALTER TABLE changelog_items CLUSTER ON changelog_items_pkey")
27
    op.execute("ALTER TABLE settings_reporting CLUSTER ON settings_reporting_pkey")
28
    op.execute("ALTER TABLE asoc_group_managers CLUSTER ON asoc_group_managers_pkey")
29
    op.execute("ALTER TABLE asoc_group_members CLUSTER ON asoc_group_members_pkey")
30
    op.execute("ALTER TABLE asoc_group_members_wanted CLUSTER ON asoc_group_members_wanted_pkey")
31

  
32

  
33
def downgrade():	# pylint: disable=locally-disabled,missing-docstring
34
    op.execute("ALTER TABLE users SET WITHOUT CLUSTER")
35
    op.execute("ALTER TABLE groups SET WITHOUT CLUSTER")
36
    op.execute("ALTER TABLE networks SET WITHOUT CLUSTER")
37
    op.execute("ALTER TABLE filters SET WITHOUT CLUSTER")
38
    op.execute("ALTER TABLE reports_events SET WITHOUT CLUSTER")
39
    op.execute("ALTER TABLE statistics_events SET WITHOUT CLUSTER")
40
    op.execute("ALTER TABLE changelog_items SET WITHOUT CLUSTER")
41
    op.execute("ALTER TABLE settings_reporting SET WITHOUT CLUSTER")
42
    op.execute("ALTER TABLE asoc_group_managers SET WITHOUT CLUSTER")
43
    op.execute("ALTER TABLE asoc_group_members SET WITHOUT CLUSTER")
44
    op.execute("ALTER TABLE asoc_group_members_wanted SET WITHOUT CLUSTER")
    (1-1/1)