Merge lp:~jml/pkgme-devportal/schema-changes into lp:pkgme-devportal

Proposed by Jonathan Lange
Status: Merged
Approved by: Jonathan Lange
Approved revision: 89
Merged at revision: 82
Proposed branch: lp:~jml/pkgme-devportal/schema-changes
Merge into: lp:pkgme-devportal
Diff against target: 43 lines (+14/-5)
2 files modified
db/patch-00001.sql (+3/-0)
devportalbinary/testing.py (+11/-5)
To merge this branch: bzr merge lp:~jml/pkgme-devportal/schema-changes
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
Jonathan Lange Approve
Review via email: mp+119883@code.launchpad.net

Commit message

Add a schema patch to add 'architecture' column to libdep table.

Description of the change

The patch to add architecture.
Updates our tests to use the schema & patch.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for this branch.

Is there a benefit of doing this manually over using the storm support for schema updates?
There is some outline how that is done in lp:~mvo/pkgme-devportal/schemas-via-storm

The code itself looks fine and +1.

Revision history for this message
Jonathan Lange (jml) wrote :

On 16 August 2012 11:38, Michael Vogt <email address hidden> wrote:
> Thanks for this branch.
>
> Is there a benefit of doing this manually over using the storm support for schema updates?
> There is some outline how that is done in lp:~mvo/pkgme-devportal/schemas-via-storm
>

Good question. I don't know the answer, but here are some thoughts::

 * webops are familiar with applying direct SQL patches
 * less can go wrong with direct SQL patches: missing dependencies,
PYTHONPATH issues, etc.
 * we don't want any schema changing code in the service itself, so
we'd have storm migration code only for tests and for deployment
 * I am personally unfamiliar with storm migrations support, and would
have to learn it to do this particular patch
 * I don't know what benefit storm migration support provides
 * this is our first schema update, and I'd like to reduce variables
 * this is our first schema update, there will be others and we are
free to do those in any fashion we wish

That sounds pretty negative, but that's mostly because I'm ignorant of
the positives.

> The code itself looks fine and +1.

Thanks,
jml

Revision history for this message
Jonathan Lange (jml) wrote :

On 16 August 2012 11:38, Michael Vogt <email address hidden> wrote:
> Thanks for this branch.
>
> Is there a benefit of doing this manually over using the storm support for schema updates?
> There is some outline how that is done in lp:~mvo/pkgme-devportal/schemas-via-storm
>

Good question. I don't know the answer, but here are some thoughts::

 * webops are familiar with applying direct SQL patches
 * less can go wrong with direct SQL patches: missing dependencies,
PYTHONPATH issues, etc.
 * we don't want any schema changing code in the service itself, so
we'd have storm migration code only for tests and for deployment
 * I am personally unfamiliar with storm migrations support, and would
have to learn it to do this particular patch
 * I don't know what benefit storm migration support provides
 * this is our first schema update, and I'd like to reduce variables
 * this is our first schema update, there will be others and we are
free to do those in any fashion we wish

That sounds pretty negative, but that's mostly because I'm ignorant of
the positives.

> The code itself looks fine and +1.

Thanks,
jml

Revision history for this message
Jonathan Lange (jml) wrote :

Taking mvo's +1 as an approval.

review: Approve
Revision history for this message
Michael Vogt (mvo) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'db/patch-00001.sql'
2--- db/patch-00001.sql 1970-01-01 00:00:00 +0000
3+++ db/patch-00001.sql 2012-08-16 10:25:35 +0000
4@@ -0,0 +1,3 @@
5+
6+ALTER TABLE libdep
7+ ADD COLUMN architecture TEXT;
8
9=== modified file 'devportalbinary/testing.py'
10--- devportalbinary/testing.py 2012-08-10 15:11:35 +0000
11+++ devportalbinary/testing.py 2012-08-16 10:25:35 +0000
12@@ -89,9 +89,11 @@
13 os.path.abspath(__file__))), 'db', name)
14
15
16-def get_postgres_schema_create_sql():
17- with open(get_db_schema_file_path('postgres_schema.sql')) as f:
18- return f.read()
19+def get_db_schema_queries(filenames):
20+ for filename in filenames:
21+ path = get_db_schema_file_path(filename)
22+ with open(path) as f:
23+ yield f.read()
24
25
26 class PostgresDatabaseFixture(Fixture):
27@@ -110,10 +112,14 @@
28
29 def create_db(self):
30 self.cluster.createdb(self.db_name)
31- postgres_schema_create = get_postgres_schema_create_sql()
32+ queries = ['postgres_schema.sql', 'patch-00001.sql']
33+ for patch in get_db_schema_queries(queries):
34+ self._execute(patch)
35+
36+ def _execute(self, query):
37 with closing(self.cluster.connect(self.db_name)) as conn:
38 cur = conn.cursor()
39- cur.execute(postgres_schema_create)
40+ cur.execute(query)
41 conn.commit()
42
43 def close_connection(self):

Subscribers

People subscribed via source and target branches