~abompard/mailman/subpolicy

« back to all changes in this revision

Viewing changes to src/mailman/database/alembic/versions/46e92facee7_add_serverowner_domainowner.py

  • Committer: Barry Warsaw
  • Date: 2015-04-07 19:21:08 UTC
  • mfrom: (7313.1.3 3.0)
  • Revision ID: barry@list.org-20150407192108-ntmhjnwm9dp03z2o
Trunk merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2015 by the Free Software Foundation, Inc.
 
2
#
 
3
# This file is part of GNU Mailman.
 
4
#
 
5
# GNU Mailman is free software: you can redistribute it and/or modify it under
 
6
# the terms of the GNU General Public License as published by the Free
 
7
# Software Foundation, either version 3 of the License, or (at your option)
 
8
# any later version.
 
9
#
 
10
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
 
11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
12
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 
13
# more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License along with
 
16
# GNU Mailman.  If not, see <http://www.gnu.org/licenses/>.
 
17
 
 
18
"""add_serverowner_domainowner
 
19
 
 
20
Revision ID: 46e92facee7
 
21
Revises: 33e1f5f6fa8
 
22
Create Date: 2015-03-20 16:01:25.007242
 
23
 
 
24
"""
 
25
 
 
26
# Revision identifiers, used by Alembic.
 
27
revision = '46e92facee7'
 
28
down_revision = '33e1f5f6fa8'
 
29
 
 
30
from alembic import op
 
31
import sqlalchemy as sa
 
32
 
 
33
 
 
34
def upgrade():
 
35
    op.create_table(
 
36
        'domain_owner',
 
37
        sa.Column('user_id', sa.Integer(), nullable=False),
 
38
        sa.Column('domain_id', sa.Integer(), nullable=False),
 
39
        sa.ForeignKeyConstraint(['domain_id'], ['domain.id'], ),
 
40
        sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
 
41
        sa.PrimaryKeyConstraint('user_id', 'domain_id')
 
42
        )
 
43
    op.add_column(
 
44
        'user',
 
45
        sa.Column('is_server_owner', sa.Boolean(), nullable=True))
 
46
    if op.get_bind().dialect.name != 'sqlite':
 
47
        op.drop_column('domain', 'contact_address')
 
48
 
 
49
 
 
50
def downgrade():
 
51
    if op.get_bind().dialect.name != 'sqlite':
 
52
        op.drop_column('user', 'is_server_owner')
 
53
        op.add_column(
 
54
            'domain',
 
55
            sa.Column('contact_address', sa.VARCHAR(), nullable=True))
 
56
    op.drop_table('domain_owner')