Merge lp:~robru/bileto/never-run-out-of-ids into lp:bileto

Proposed by Robert Bruce Park
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 302
Merged at revision: 298
Proposed branch: lp:~robru/bileto/never-run-out-of-ids
Merge into: lp:bileto
Diff against target: 68 lines (+15/-4)
2 files modified
db_migrations.sh (+5/-1)
tickets/models.py (+10/-3)
To merge this branch: bzr merge lp:~robru/bileto/never-run-out-of-ids
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Robert Bruce Park (community) Approve
Review via email: mp+274033@code.launchpad.net

Commit message

Convert id columns to bigint Just In Case.

To post a comment you must log in.
Revision history for this message
Robert Bruce Park (robru) wrote :

Worked in staging.

review: Approve
300. By Robert Bruce Park

Use BigInteger in models too

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:300
http://jenkins.qa.ubuntu.com/job/bileto-ci/74/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/bileto-ci/74/rebuild

review: Needs Fixing (continuous-integration)
301. By Robert Bruce Park

Use INTEGER in sqlite to work around bug.

302. By Robert Bruce Park

Use BIGINT for postgres and INTEGER for sqlite.

Revision history for this message
Robert Bruce Park (robru) wrote :

Reconfirmed in staging.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:302
http://jenkins.qa.ubuntu.com/job/bileto-ci/75/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/bileto-ci/75/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'db_migrations.sh'
2--- db_migrations.sh 2015-09-30 21:07:31 +0000
3+++ db_migrations.sh 2015-10-09 22:16:50 +0000
4@@ -3,7 +3,7 @@
5 # Super ultra-lightweight db migrations crafted by hand because the necessary
6 # flask/sqlalchemy migrations bits aren't available for python3 in trusty.
7
8-exit 0 # No migrations are currently required.
9+# exit 0 # No migrations are currently required.
10
11 CONNECTION=$(tr ':/@' ' ' < "$HOME/bileto.postgresql.info")
12 USER=$(echo "$CONNECTION" | awk '{ print $2 }')
13@@ -26,6 +26,10 @@
14 $PG "SELECT pg_terminate_backend($pid);"
15 done
16
17+$PG "ALTER TABLE comment ALTER COLUMN request_id SET DATA TYPE bigint;"
18+$PG "ALTER TABLE comment ALTER COLUMN id SET DATA TYPE bigint;"
19+$PG "ALTER TABLE request ALTER COLUMN request_id SET DATA TYPE bigint;"
20+
21 # These ones have succeeded in production and only kept for reference
22 # $PG "ALTER TABLE comment ADD COLUMN log_url text DEFAULT '';" || true
23 # $PG "ALTER TABLE comment ADD COLUMN published_versions text DEFAULT '';" || true
24
25=== modified file 'tickets/models.py'
26--- tickets/models.py 2015-10-06 23:59:17 +0000
27+++ tickets/models.py 2015-10-09 22:16:50 +0000
28@@ -8,12 +8,19 @@
29
30 from flask import session
31 from datetime import datetime
32+from sqlalchemy import BigInteger
33+from sqlalchemy.dialects import sqlite
34 from sqlalchemy.orm import relationship
35 from sqlalchemy.inspection import inspect
36
37 from tickets.app import db
38
39
40+# SQLite can't handle the BigInts, so we overload that for unit tests.
41+# Behaves like proper bigint should in production postgres.
42+BigInt = BigInteger().with_variant(sqlite.INTEGER(), 'sqlite')
43+
44+
45 CHAR_MAX = 1000
46 WORD = re.compile('\W+')
47
48@@ -133,7 +140,7 @@
49 class Request(db.Model, BiletoModel):
50 """Contains all data associated with one landing request."""
51 request_id = db.Column(
52- db.Integer, primary_key=True, doc='Request ID')
53+ BigInt, primary_key=True, doc='Request ID')
54 date = db.Column(db.DateTime, default=right_now, doc='Creation Date')
55
56 test_plan = db.Column(db.Text, default='', doc=TEST_PLAN)
57@@ -210,9 +217,9 @@
58
59 class Comment(db.Model, BiletoModel):
60 """Stores one comment on a landing request."""
61- id = db.Column(db.Integer, primary_key=True)
62+ id = db.Column(BigInt, primary_key=True)
63 request_id = db.Column(
64- db.Integer, db.ForeignKey(Request.request_id), nullable=False)
65+ BigInt, db.ForeignKey(Request.request_id), nullable=False)
66 author = db.Column(db.Text, nullable=False)
67 text = db.Column(db.Text, default='')
68 date = db.Column(db.DateTime, default=right_now)

Subscribers

People subscribed via source and target branches