Merge lp:~trb143/openlp/bug-815313 into lp:openlp

Proposed by Tim Bentley
Status: Merged
Merged at revision: 1724
Proposed branch: lp:~trb143/openlp/bug-815313
Merge into: lp:openlp
Diff against target: 70 lines (+20/-5)
2 files modified
openlp/plugins/songs/lib/db.py (+5/-1)
openlp/plugins/songs/lib/upgrade.py (+15/-4)
To merge this branch: bzr merge lp:~trb143/openlp/bug-815313
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Review via email: mp+73045@code.launchpad.net

This proposal supersedes a proposal from 2011-08-26.

Description of the change

Adds two dates to the song database.
Sets up the initial values on creation
Updates the updated value when changes happen.

Tested on a changed database (Raouls)
Tested on a clean database (Raouls and mine)
Editied a song
Added and edited a song.

To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Works for me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/plugins/songs/lib/db.py'
2--- openlp/plugins/songs/lib/db.py 2011-08-25 09:22:48 +0000
3+++ openlp/plugins/songs/lib/db.py 2011-08-26 13:16:50 +0000
4@@ -31,6 +31,7 @@
5
6 from sqlalchemy import Column, ForeignKey, Table, types
7 from sqlalchemy.orm import mapper, relation
8+from sqlalchemy.sql.expression import func
9
10 from openlp.core.lib.db import BaseModel, init_db
11
12@@ -195,7 +196,10 @@
13 Column(u'song_number', types.Unicode(64)),
14 Column(u'theme_name', types.Unicode(128)),
15 Column(u'search_title', types.Unicode(255), index=True, nullable=False),
16- Column(u'search_lyrics', types.UnicodeText, nullable=False)
17+ Column(u'search_lyrics', types.UnicodeText, nullable=False),
18+ Column(u'create_date', types.DateTime(), default=func.now()),
19+ Column(u'last_modified', types.DateTime(), default=func.now(),
20+ onupdate=func.now())
21 )
22
23 # Definition of the "topics" table
24
25=== modified file 'openlp/plugins/songs/lib/upgrade.py'
26--- openlp/plugins/songs/lib/upgrade.py 2011-08-25 20:14:02 +0000
27+++ openlp/plugins/songs/lib/upgrade.py 2011-08-26 13:16:50 +0000
28@@ -25,15 +25,16 @@
29 # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
30 ###############################################################################
31 """
32-The :mod:`upgrade` module provides a way for the database and schema that is the backend for
33-the Songs plugin
34+The :mod:`upgrade` module provides a way for the database and schema that is the
35+backend for the Songs plugin
36 """
37
38 from sqlalchemy import Column, ForeignKey, Table, types
39+from sqlalchemy.sql.expression import func
40 from migrate import changeset
41 from migrate.changeset.constraint import ForeignKeyConstraint
42
43-__version__ = 1
44+__version__ = 2
45
46 def upgrade_setup(metadata):
47 """
48@@ -57,7 +58,7 @@
49 """
50 Version 1 upgrade.
51
52- This upgrade removes the many-to-many relationship between songs and
53+ This upgrade removes the many-to-many relationship between songs and
54 media_files and replaces it with a one-to-many, which is far more
55 representative of the real relationship between the two entities.
56
57@@ -75,3 +76,13 @@
58 ForeignKeyConstraint([u'song_id'], [u'songs.id'],
59 table=tables[u'media_files']).create()
60
61+def upgrade_2(session, metadata, tables):
62+ """
63+ Version 2 upgrade.
64+
65+ This upgrade adds a create_date and last_modified date to the songs table
66+ """
67+ Column(u'create_date', types.DateTime(), default=func.now())\
68+ .create(table=tables[u'songs'], populate_default=True)
69+ Column(u'last_modified', types.DateTime(), default=func.now())\
70+ .create(table=tables[u'songs'], populate_default=True)