forked from magma/magma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dp): Add available frequencies column (magma#13089)
Signed-off-by: Kuba Marciniszyn <kuba@freedomfi.com>
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
dp/cloud/python/magma/db_service/migrations/versions/530b18568ad9_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
dp/cloud/python/magma/db_service/tests/unit/test_530b18568ad9.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |