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

Proposed by Tim Bentley
Status: Superseded
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
OpenLP Core Pending
Review via email: mp+73040@code.launchpad.net

This proposal has been superseded by 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.
lp:~trb143/openlp/bug-815313 updated
1721. By Tim Bentley

Fix default value

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/plugins/songs/lib/db.py'
--- openlp/plugins/songs/lib/db.py 2011-08-25 09:22:48 +0000
+++ openlp/plugins/songs/lib/db.py 2011-08-26 13:15:18 +0000
@@ -31,6 +31,7 @@
3131
32from sqlalchemy import Column, ForeignKey, Table, types32from sqlalchemy import Column, ForeignKey, Table, types
33from sqlalchemy.orm import mapper, relation33from sqlalchemy.orm import mapper, relation
34from sqlalchemy.sql.expression import func
3435
35from openlp.core.lib.db import BaseModel, init_db36from openlp.core.lib.db import BaseModel, init_db
3637
@@ -195,7 +196,10 @@
195 Column(u'song_number', types.Unicode(64)),196 Column(u'song_number', types.Unicode(64)),
196 Column(u'theme_name', types.Unicode(128)),197 Column(u'theme_name', types.Unicode(128)),
197 Column(u'search_title', types.Unicode(255), index=True, nullable=False),198 Column(u'search_title', types.Unicode(255), index=True, nullable=False),
198 Column(u'search_lyrics', types.UnicodeText, nullable=False)199 Column(u'search_lyrics', types.UnicodeText, nullable=False),
200 Column(u'create_date', types.DateTime(), default=func.now()),
201 Column(u'last_modified', types.DateTime(), default=func.now(),
202 onupdate=func.now())
199 )203 )
200204
201 # Definition of the "topics" table205 # Definition of the "topics" table
202206
=== modified file 'openlp/plugins/songs/lib/upgrade.py'
--- openlp/plugins/songs/lib/upgrade.py 2011-08-25 20:14:02 +0000
+++ openlp/plugins/songs/lib/upgrade.py 2011-08-26 13:15:18 +0000
@@ -25,15 +25,16 @@
25# Temple Place, Suite 330, Boston, MA 02111-1307 USA #25# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
26###############################################################################26###############################################################################
27"""27"""
28The :mod:`upgrade` module provides a way for the database and schema that is the backend for28The :mod:`upgrade` module provides a way for the database and schema that is the
29the Songs plugin29backend for the Songs plugin
30"""30"""
3131
32from sqlalchemy import Column, ForeignKey, Table, types32from sqlalchemy import Column, ForeignKey, Table, types
33from sqlalchemy.sql.expression import func
33from migrate import changeset34from migrate import changeset
34from migrate.changeset.constraint import ForeignKeyConstraint35from migrate.changeset.constraint import ForeignKeyConstraint
3536
36__version__ = 137__version__ = 2
3738
38def upgrade_setup(metadata):39def upgrade_setup(metadata):
39 """40 """
@@ -57,7 +58,7 @@
57 """58 """
58 Version 1 upgrade.59 Version 1 upgrade.
5960
60 This upgrade removes the many-to-many relationship between songs and 61 This upgrade removes the many-to-many relationship between songs and
61 media_files and replaces it with a one-to-many, which is far more62 media_files and replaces it with a one-to-many, which is far more
62 representative of the real relationship between the two entities.63 representative of the real relationship between the two entities.
6364
@@ -75,3 +76,13 @@
75 ForeignKeyConstraint([u'song_id'], [u'songs.id'],76 ForeignKeyConstraint([u'song_id'], [u'songs.id'],
76 table=tables[u'media_files']).create()77 table=tables[u'media_files']).create()
7778
79def upgrade_2(session, metadata, tables):
80 """
81 Version 2 upgrade.
82
83 This upgrade adds a create_date and last_modified date to the songs table
84 """
85 Column(u'create_date', types.DateTime(), default=func.now())\
86 .create(table=tables[u'songs'], populate_default=True)
87 Column(u'last_modified', types.DateTime(), default=func.now())\
88 .create(table=tables[u'songs'], populate_default=True)