Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'db_lengths' of git://github.com/andrewjcg/buildbot
- Loading branch information
Showing
5 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
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
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
34 changes: 34 additions & 0 deletions
34
master/buildbot/db/migrate/versions/023_increase_comments_property_lengths.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,34 @@ | ||
# This file is part of Buildbot. Buildbot is free software: you can | ||
# redistribute it and/or modify it under the terms of the GNU General Public | ||
# License as published by the Free Software Foundation, version 2. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, write to the Free Software Foundation, Inc., 51 | ||
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Copyright Buildbot Team Members | ||
|
||
import sqlalchemy as sa | ||
from migrate import changeset | ||
|
||
def upgrade(migrate_engine): | ||
metadata = sa.MetaData() | ||
metadata.bind = migrate_engine | ||
|
||
# Some property values and change comments can get too big | ||
# for the normal 1024 String limit. | ||
changeset.alter_column( | ||
sa.Column('property_value', sa.Text, nullable=False), | ||
table='buildset_properties', | ||
metadata=metadata, | ||
engine=migrate_engine) | ||
changeset.alter_column( | ||
sa.Column('comments', sa.Text, nullable=False), | ||
table='changes', | ||
metadata=metadata, | ||
engine=migrate_engine) |
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
60 changes: 60 additions & 0 deletions
60
master/buildbot/test/unit/test_db_migrate_versions_023_increase_comments_property_lengths.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,60 @@ | ||
# This file is part of Buildbot. Buildbot is free software: you can | ||
# redistribute it and/or modify it under the terms of the GNU General Public | ||
# License as published by the Free Software Foundation, version 2. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, write to the Free Software Foundation, Inc., 51 | ||
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Copyright Buildbot Team Members | ||
|
||
import sqlalchemy as sa | ||
from twisted.trial import unittest | ||
from buildbot.test.util import migration | ||
|
||
class Migration(migration.MigrateTestMixin, unittest.TestCase): | ||
|
||
table_columns = [ | ||
('changes', 'comments'), | ||
('buildset_properties', 'property_value'), | ||
] | ||
|
||
def setUp(self): | ||
return self.setUpMigrateTest() | ||
|
||
def tearDown(self): | ||
return self.tearDownMigrateTest() | ||
|
||
def create_tables_thd(self, conn): | ||
metadata = sa.MetaData() | ||
metadata.bind = conn | ||
|
||
# Create the tables/columns we're testing | ||
for table, column in self.table_columns: | ||
tbl = sa.Table(table, metadata, | ||
sa.Column(column, sa.String(1024), nullable=False), | ||
# the rest is unimportant | ||
) | ||
tbl.create() | ||
|
||
# tests | ||
|
||
def test_update(self): | ||
def setup_thd(conn): | ||
self.create_tables_thd(conn) | ||
|
||
def verify_thd(conn): | ||
metadata = sa.MetaData() | ||
metadata.bind = conn | ||
|
||
# Verify that the columns have been upate to the Text type. | ||
for table, column in self.table_columns: | ||
tbl = sa.Table(table, metadata, autoload=True) | ||
self.assertIsInstance(getattr(tbl.c, column).type, sa.Text) | ||
|
||
return self.do_test_migration(22, 23, setup_thd, verify_thd) |