Skip to content

Commit

Permalink
feat(dp): Add available frequencies column (magma#13089)
Browse files Browse the repository at this point in the history
Signed-off-by: Kuba Marciniszyn <kuba@freedomfi.com>
  • Loading branch information
jkmar authored and emakeev committed Aug 5, 2022
1 parent 9aa705d commit f3c3caf
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""empty message
Revision ID: 530b18568ad9
Revises: b5caf147315e
Create Date: 2022-06-27 15:55:48.080182
"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = '530b18568ad9'
down_revision = 'b5caf147315e'
branch_labels = None
depends_on = None


def upgrade():
"""
Run upgrade
"""
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('cbsds', sa.Column('available_frequencies', sa.JSON(), nullable=True))
# ### end Alembic commands ###


def downgrade():
"""
Run downgrade
"""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('cbsds', 'available_frequencies')
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions dp/cloud/python/magma/db_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class DBCbsd(Base):
carrier_aggregation_enabled = Column(Boolean, nullable=False, server_default='false')
max_ibw_mhz = Column(Integer, nullable=False, server_default='150')
grant_redundancy = Column(Boolean, nullable=False, server_default='true')
available_frequencies = Column(JSON)
created_date = Column(
DateTime(timezone=True),
nullable=False, server_default=now(),
Expand Down
35 changes: 35 additions & 0 deletions dp/cloud/python/magma/db_service/tests/unit/test_530b18568ad9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Copyright 2022 The Magma Authors.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from magma.db_service.tests.alembic_testcase import AlembicTestCase

# TODO make some generic test for migration with only column changes
TABLE = 'cbsds'
COLUMN = 'available_frequencies'


class Test530b18568ad9TestCase(AlembicTestCase):
down_revision = 'b5caf147315e'
up_revision = '530b18568ad9'

def setUp(self) -> None:
super().setUp()
self.upgrade(self.down_revision)

def test_upgrade(self):
self.upgrade()
self.assertTrue(self.has_column(self.get_table(TABLE), COLUMN))

def test_columns_present_post_upgrade(self):
self.upgrade()
self.downgrade()
self.assertFalse(self.has_column(self.get_table(TABLE), COLUMN))

0 comments on commit f3c3caf

Please sign in to comment.