forked from openlp/openlp
Add audio files to DB
This commit is contained in:
parent
dd8c6f378b
commit
9e2b876be3
@ -32,6 +32,12 @@ from sqlalchemy.orm import mapper, relation
|
|||||||
|
|
||||||
from openlp.core.lib.db import BaseModel, init_db
|
from openlp.core.lib.db import BaseModel, init_db
|
||||||
|
|
||||||
|
class AudioFile(BaseModel):
|
||||||
|
"""
|
||||||
|
AudioFile model
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
class Author(BaseModel):
|
class Author(BaseModel):
|
||||||
"""
|
"""
|
||||||
Author model
|
Author model
|
||||||
@ -75,6 +81,12 @@ def init_schema(url):
|
|||||||
Column(u'display_name', types.Unicode(255), nullable=False)
|
Column(u'display_name', types.Unicode(255), nullable=False)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Definition of the "audio_files" table
|
||||||
|
audio_files_table = Table(u'audio_files', metadata,
|
||||||
|
Column(u'id', types.Integer, primary_key=True),
|
||||||
|
Column(u'file_name', types.Unicode(255), nullable=False)
|
||||||
|
)
|
||||||
|
|
||||||
# Definition of the "song_books" table
|
# Definition of the "song_books" table
|
||||||
song_books_table = Table(u'song_books', metadata,
|
song_books_table = Table(u'song_books', metadata,
|
||||||
Column(u'id', types.Integer, primary_key=True),
|
Column(u'id', types.Integer, primary_key=True),
|
||||||
@ -114,6 +126,14 @@ def init_schema(url):
|
|||||||
ForeignKey(u'songs.id'), primary_key=True)
|
ForeignKey(u'songs.id'), primary_key=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Definition of the "songs_audio_files" table
|
||||||
|
songs_audio_files_table = Table(u'songs_audio_files', metadata,
|
||||||
|
Column(u'song_id', types.Integer,
|
||||||
|
ForeignKey(u'songs.id'), primary_key=True),
|
||||||
|
Column(u'audio_file_id', types.Integer,
|
||||||
|
ForeignKey(u'audio_files.id'), primary_key=True)
|
||||||
|
)
|
||||||
|
|
||||||
# Definition of the "songs_topics" table
|
# Definition of the "songs_topics" table
|
||||||
songs_topics_table = Table(u'songs_topics', metadata,
|
songs_topics_table = Table(u'songs_topics', metadata,
|
||||||
Column(u'song_id', types.Integer,
|
Column(u'song_id', types.Integer,
|
||||||
@ -123,6 +143,7 @@ def init_schema(url):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Define table indexes
|
# Define table indexes
|
||||||
|
Index(u'audio_files_id', audio_files_table.c.id)
|
||||||
Index(u'authors_id', authors_table.c.id)
|
Index(u'authors_id', authors_table.c.id)
|
||||||
Index(u'authors_display_name_id', authors_table.c.display_name,
|
Index(u'authors_display_name_id', authors_table.c.display_name,
|
||||||
authors_table.c.id)
|
authors_table.c.id)
|
||||||
@ -133,19 +154,28 @@ def init_schema(url):
|
|||||||
authors_songs_table.c.song_id)
|
authors_songs_table.c.song_id)
|
||||||
Index(u'authors_songs_song', authors_songs_table.c.song_id,
|
Index(u'authors_songs_song', authors_songs_table.c.song_id,
|
||||||
authors_songs_table.c.author_id)
|
authors_songs_table.c.author_id)
|
||||||
|
Index(u'songs_audio_files_file', songs_audio_files_table.c.audio_file_id,
|
||||||
|
songs_audio_files_table.c.song_id)
|
||||||
|
Index(u'songs_audio_files_song', songs_audio_files_table.c.song_id,
|
||||||
|
songs_audio_files_table.c.audio_file_id)
|
||||||
Index(u'topics_song_topic', songs_topics_table.c.topic_id,
|
Index(u'topics_song_topic', songs_topics_table.c.topic_id,
|
||||||
songs_topics_table.c.song_id)
|
songs_topics_table.c.song_id)
|
||||||
Index(u'topics_song_song', songs_topics_table.c.song_id,
|
Index(u'topics_song_song', songs_topics_table.c.song_id,
|
||||||
songs_topics_table.c.topic_id)
|
songs_topics_table.c.topic_id)
|
||||||
|
|
||||||
|
mapper(AudioFile, audio_files_table)
|
||||||
mapper(Author, authors_table)
|
mapper(Author, authors_table)
|
||||||
mapper(Book, song_books_table)
|
mapper(Book, song_books_table)
|
||||||
mapper(Song, songs_table,
|
mapper(Song, songs_table,
|
||||||
properties={'authors': relation(Author, backref='songs',
|
properties={
|
||||||
|
'audio_files': relation(AudioFile, backref='songs',
|
||||||
|
secondary=songs_audio_files_table),
|
||||||
|
'authors': relation(Author, backref='songs',
|
||||||
secondary=authors_songs_table),
|
secondary=authors_songs_table),
|
||||||
'book': relation(Book, backref='songs'),
|
'book': relation(Book, backref='songs'),
|
||||||
'topics': relation(Topic, backref='songs',
|
'topics': relation(Topic, backref='songs',
|
||||||
secondary=songs_topics_table)})
|
secondary=songs_topics_table)
|
||||||
|
})
|
||||||
mapper(Topic, topics_table)
|
mapper(Topic, topics_table)
|
||||||
|
|
||||||
metadata.create_all(checkfirst=True)
|
metadata.create_all(checkfirst=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user