Skip to content

Commit

Permalink
Merge branch 'db_lengths' of git://github.com/andrewjcg/buildbot
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed May 11, 2013
2 parents 61f10c2 + 358a055 commit 5417265
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 5 deletions.
2 changes: 0 additions & 2 deletions master/buildbot/db/buildsets.py
Expand Up @@ -59,8 +59,6 @@ def thd(conn):
for i in inserts:
self.check_length(bs_props_tbl.c.property_name,
i['property_name'])
self.check_length(bs_props_tbl.c.property_value,
i['property_value'])

conn.execute(bs_props_tbl.insert(), inserts)

Expand Down
1 change: 0 additions & 1 deletion master/buildbot/db/changes.py
Expand Up @@ -56,7 +56,6 @@ def thd(conn):
ch_tbl = self.db.model.changes

self.check_length(ch_tbl.c.author, author)
self.check_length(ch_tbl.c.comments, comments)
self.check_length(ch_tbl.c.branch, branch)
self.check_length(ch_tbl.c.revision, revision)
self.check_length(ch_tbl.c.revlink, revlink)
Expand Down
@@ -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)
4 changes: 2 additions & 2 deletions master/buildbot/db/model.py
Expand Up @@ -105,7 +105,7 @@ class Model(base.DBConnectorComponent):
nullable=False),
sa.Column('property_name', sa.String(256), nullable=False),
# JSON-encoded tuple of (value, source)
sa.Column('property_value', sa.String(1024), nullable=False),
sa.Column('property_value', sa.Text, nullable=False),
)

# This table represents Buildsets - sets of BuildRequests that share the
Expand Down Expand Up @@ -173,7 +173,7 @@ class Model(base.DBConnectorComponent):
sa.Column('author', sa.String(256), nullable=False),

# commit comment
sa.Column('comments', sa.String(1024), nullable=False),
sa.Column('comments', sa.Text, nullable=False),

# old, CVS-related boolean
sa.Column('is_dir', sa.SmallInteger, nullable=False), # old, for CVS
Expand Down
@@ -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)

0 comments on commit 5417265

Please sign in to comment.