tables.py 17.3 KB
Newer Older
Lukáš Lalinský's avatar
Lukáš Lalinský committed
1
import sqlalchemy
Lukáš Lalinský's avatar
Lukáš Lalinský committed
2 3
import sqlalchemy.event
from sqlalchemy import (
Lukáš Lalinský's avatar
Lukáš Lalinský committed
4
    MetaData, Table, Column, Index, Sequence,
Lukáš Lalinský's avatar
Lukáš Lalinský committed
5 6
    ForeignKey, CheckConstraint,
    Integer, String, DateTime, Boolean, Date, Text, SmallInteger, BigInteger, CHAR,
Lukáš Lalinský's avatar
Lukáš Lalinský committed
7
    DDL, sql,
Lukáš Lalinský's avatar
Lukáš Lalinský committed
8 9
)
from sqlalchemy.dialects.postgresql import ARRAY, UUID, INET
Lukáš Lalinský's avatar
Lukáš Lalinský committed
10

Lukáš Lalinský's avatar
Lukáš Lalinský committed
11 12 13
metadata = MetaData(naming_convention={
    'fk': '%(table_name)s_fk_%(column_0_name)s',
    'ix': '%(table_name)s_idx_%(column_0_name)s',
Lukáš Lalinský's avatar
Lukáš Lalinský committed
14
    'pk': '%(table_name)s_pkey',
Lukáš Lalinský's avatar
Lukáš Lalinský committed
15
})
Lukáš Lalinský's avatar
Lukáš Lalinský committed
16

Lukáš Lalinský's avatar
Lukáš Lalinský committed
17
import mbdata.config  # noqa: E402
Lukáš Lalinský's avatar
Lukáš Lalinský committed
18
mbdata.config.configure(metadata=metadata, schema='musicbrainz')
19

Lukáš Lalinský's avatar
Lukáš Lalinský committed
20 21 22 23
sqlalchemy.event.listen(
    metadata, 'before_create',
    DDL('CREATE SCHEMA IF NOT EXISTS musicbrainz'),
)
Lukáš Lalinský's avatar
Lukáš Lalinský committed
24

Lukáš Lalinský's avatar
Lukáš Lalinský committed
25

Lukáš Lalinský's avatar
Lukáš Lalinský committed
26 27 28 29 30 31 32 33
def create_replication_control_table(name):
    return Table(name, metadata,
        Column('id', Integer, primary_key=True),
        Column('current_schema_sequence', Integer, nullable=False),
        Column('current_replication_sequence', Integer),
        Column('last_replication_date', DateTime(timezone=True)),
    )

Lukáš Lalinský's avatar
Lukáš Lalinský committed
34

Lukáš Lalinský's avatar
Lukáš Lalinský committed
35 36
replication_control = create_replication_control_table('replication_control')
acoustid_mb_replication_control = create_replication_control_table('acoustid_mb_replication_control')
Lukáš Lalinský's avatar
Lukáš Lalinský committed
37

38 39
account = Table('account', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
40 41
    Column('name', String, nullable=False),
    Column('apikey', String, nullable=False),
42
    Column('mbuser', String),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
43
    Column('anonymous', Boolean, default=False, server_default=sql.false()),
44
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
45 46
    Column('lastlogin', DateTime(timezone=True)),
    Column('submission_count', Integer, nullable=False, server_default=sql.literal(0)),
47 48
    Column('application_id', Integer, ForeignKey('application.id')),
    Column('application_version', String),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
49
    Column('created_from', INET),
50
    Column('is_admin', Boolean, default=False, server_default=sql.false(), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
51 52 53 54 55 56 57
    Index('account_idx_mbuser', 'mbuser', unique=True),
    Index('account_idx_apikey', 'apikey', unique=True),
)

account_stats_control = Table('account_stats_control', metadata,
    Column('id', Integer, primary_key=True),
    Column('last_updated', DateTime(timezone=True), nullable=False),
58 59
)

60 61
account_openid = Table('account_openid', metadata,
    Column('openid', String, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
62 63
    Column('account_id', Integer, ForeignKey('account.id'), nullable=False),
    Index('account_openid_idx_account_id', 'account_id'),
64 65
)

Lukáš Lalinský's avatar
Lukáš Lalinský committed
66 67
account_google = Table('account_google', metadata,
    Column('google_user_id', String, primary_key=True),
68
    Column('account_id', Integer, ForeignKey('account.id'), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
69
    Index('account_google_idx_account_id', 'account_id'),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
70 71
)

72 73
application = Table('application', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
74 75 76
    Column('name', String, nullable=False),
    Column('version', String, nullable=False),
    Column('apikey', String, nullable=False),
77
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
78
    Column('active', Boolean, default=True, server_default=sql.true()),
79
    Column('account_id', Integer, ForeignKey('account.id'), nullable=False),
80 81
    Column('email', String),
    Column('website', String),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
82
    Index('application_idx_apikey', 'apikey', unique=True),
83 84
)

Lukáš Lalinský's avatar
Lukáš Lalinský committed
85 86
track = Table('track', metadata,
    Column('id', Integer, primary_key=True),
87
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
88 89 90
    Column('new_id', Integer, ForeignKey('track.id')),
    Column('gid', UUID, nullable=False),
    Index('track_idx_gid', 'gid', unique=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
91 92
)

93 94
format = Table('format', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
95 96
    Column('name', String, nullable=False),
    Index('format_idx_name', 'name', unique=True),
97 98
)

99 100
source = Table('source', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
101 102
    Column('application_id', Integer, ForeignKey('application.id'), nullable=False),
    Column('account_id', Integer, ForeignKey('account.id'), nullable=False),
103
    Column('version', String),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
104
    Index('source_idx_uniq', 'application_id', 'account_id', 'version', unique=True),
105 106
)

Lukáš Lalinský's avatar
Lukáš Lalinský committed
107
submission_old = Table('submission_old', metadata,
108
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
109 110 111
    Column('fingerprint', ARRAY(Integer), nullable=False),
    Column('length', SmallInteger, CheckConstraint('length>0'), nullable=False),
    Column('bitrate', SmallInteger, CheckConstraint('bitrate>0')),
112
    Column('format_id', Integer, ForeignKey('format.id')),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
113 114 115 116 117
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
    Column('source_id', Integer, ForeignKey('source.id'), nullable=False),
    Column('mbid', UUID),
    Column('handled', Boolean, default=False, server_default=sql.false()),
    Column('puid', UUID),
118
    Column('meta_id', Integer, ForeignKey('meta.id')),
119
    Column('foreignid_id', Integer, ForeignKey('foreignid.id')),
120 121
)

Lukáš Lalinský's avatar
Lukáš Lalinský committed
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
Index('submission_idx_handled', submission_old.c.id, postgresql_where=submission_old.c.handled == False)  # noqa: E712

submission_id_seq = Sequence('submission_id_seq', metadata=metadata)

submission = Table('submission', metadata,
    Column('id', Integer, submission_id_seq, server_default=submission_id_seq.next_value(), primary_key=True),
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
    Column('handled', Boolean, default=False, server_default=sql.false()),

    Column('account_id', Integer, nullable=False),  # ForeignKey('account.id')
    Column('application_id', Integer, nullable=False),  # ForeignKey('application.id')
    Column('application_version', String),

    Column('fingerprint', ARRAY(Integer), nullable=False),
    Column('duration', Integer, CheckConstraint('duration>0'), nullable=False),
    Column('bitrate', Integer, CheckConstraint('bitrate>0')),
    Column('format', String),
    Column('mbid', UUID),
    Column('puid', UUID),
    Column('foreignid', String),

    Column('track', String),
    Column('artist', String),
    Column('album', String),
    Column('album_artist', String),
    Column('track_no', Integer),
    Column('disc_no', Integer),
    Column('year', Integer),

    info={'bind_key': 'slow'},
)

submission_result = Table('submission_result', metadata,
    Column('submission_id', Integer, primary_key=True, autoincrement=False),
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),

    Column('account_id', Integer, nullable=False),  # ForeignKey('account.id')
    Column('application_id', Integer, nullable=False),  # ForeignKey('application.id')
    Column('application_version', String),

    Column('fingerprint_id', Integer, nullable=False),  # ForeignKey('fingerprint.id')
    Column('track_id', Integer, nullable=False),  # ForeignKey('track.id')
    Column('meta_id', Integer),  # ForeignKey('meta.id')
    Column('mbid', UUID),
    Column('puid', UUID),
    Column('foreignid', String),

    info={'bind_key': 'slow'},
)
Lukáš Lalinský's avatar
Lukáš Lalinský committed
171

172 173
stats = Table('stats', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
174 175 176 177 178
    Column('name', String, nullable=False),
    Column('date', Date, server_default=sql.func.current_date(), nullable=False),
    Column('value', Integer, nullable=False),
    Index('stats_idx_date', 'date'),
    Index('stats_idx_name_date', 'name', 'date'),
179 180
)

181 182
stats_lookups = Table('stats_lookups', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
183 184
    Column('date', Date, nullable=False),
    Column('hour', Integer, nullable=False),
185
    Column('application_id', Integer, ForeignKey('application.id'), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
186 187 188
    Column('count_nohits', Integer, default=0, server_default=sql.literal(0), nullable=False),
    Column('count_hits', Integer, default=0, server_default=sql.literal(0), nullable=False),
    Index('stats_lookups_idx_date', 'date'),
189 190
)

Lukáš Lalinský's avatar
Lukáš Lalinský committed
191 192
stats_user_agents = Table('stats_user_agents', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
193
    Column('date', Date, nullable=False),
194
    Column('application_id', Integer, ForeignKey('application.id'), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
195 196 197 198
    Column('user_agent', String, nullable=False),
    Column('ip', String, nullable=False),
    Column('count', Integer, default=0, server_default=sql.literal(0), nullable=False),
    Index('stats_user_agents_idx_date', 'date'),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
199 200
)

201 202
stats_top_accounts = Table('stats_top_accounts', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
203 204
    Column('account_id', Integer, ForeignKey('account.id'), nullable=False),
    Column('count', Integer, nullable=False),
205 206
)

207 208 209 210 211 212 213 214 215 216 217
meta = Table('meta', metadata,
    Column('id', Integer, primary_key=True),
    Column('track', String),
    Column('artist', String),
    Column('album', String),
    Column('album_artist', String),
    Column('track_no', Integer),
    Column('disc_no', Integer),
    Column('year', Integer),
)

218 219
foreignid_vendor = Table('foreignid_vendor', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
220 221
    Column('name', String, nullable=False),
    Index('foreignid_vendor_idx_name', 'name', unique=True),
222 223 224 225
)

foreignid = Table('foreignid', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
226 227 228 229
    Column('vendor_id', Integer, ForeignKey('foreignid_vendor.id'), nullable=False),
    Column('name', Text, nullable=False),
    Index('foreignid_idx_vendor', 'vendor_id'),
    Index('foreignid_idx_vendor_name', 'vendor_id', 'name', unique=True),
230 231
)

232 233
fingerprint = Table('fingerprint', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
234 235 236
    Column('fingerprint', ARRAY(Integer), nullable=False),
    Column('length', SmallInteger, CheckConstraint('length>0'), nullable=False),
    Column('bitrate', SmallInteger, CheckConstraint('bitrate>0')),
237
    Column('format_id', Integer, ForeignKey('format.id')),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
238 239 240 241 242
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
    Column('track_id', Integer, ForeignKey('track.id'), nullable=False),
    Column('submission_count', Integer, nullable=False),
    Index('fingerprint_idx_length', 'length'),
    Index('fingerprint_idx_track_id', 'track_id'),
243 244
)

Lukáš Lalinský's avatar
Lukáš Lalinský committed
245 246
fingerprint.add_is_dependent_on(track)

247 248
fingerprint_source = Table('fingerprint_source', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
249
    Column('fingerprint_id', Integer, ForeignKey('fingerprint.id'), nullable=False),
250
    Column('submission_id', Integer, nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
251
    Column('source_id', Integer, ForeignKey('source.id'), nullable=False),
252
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
253
    Index('fingerprint_source_idx_submission_id', 'submission_id'),
254 255
)

256
fingerprint_index_queue = Table('fingerprint_index_queue', metadata,
Lukáš Lalinský's avatar
Lukáš Lalinský committed
257
    Column('fingerprint_id', Integer, nullable=False),
258 259
)

Lukáš Lalinský's avatar
Lukáš Lalinský committed
260
track_mbid = Table('track_mbid', metadata,
Lukáš Lalinský's avatar
Lukáš Lalinský committed
261 262
    Column('track_id', Integer, ForeignKey('track.id'), nullable=False),
    Column('mbid', UUID, nullable=False, index=True),
263
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
264
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
265 266
    Column('submission_count', Integer, nullable=False),
    Column('disabled', Boolean, default=False, server_default=sql.false(), nullable=False),
267
    Index('track_mbid_idx_uniq', 'track_id', 'mbid', unique=True),
268 269
)

270 271
track_mbid_source = Table('track_mbid_source', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
272
    Column('track_mbid_id', Integer, ForeignKey('track_mbid.id'), nullable=False, index=True),
273
    Column('submission_id', Integer),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
274
    Column('source_id', Integer, ForeignKey('source.id'), nullable=False, index=True),
275
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
276 277
)

278 279
track_mbid_change = Table('track_mbid_change', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
280 281
    Column('track_mbid_id', Integer, ForeignKey('track_mbid.id'), nullable=False, index=True),
    Column('account_id', Integer, ForeignKey('account.id'), nullable=False),
282
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
283
    Column('disabled', Boolean, nullable=False),
284
    Column('note', Text),
285 286
)

287 288
track_mbid_flag = Table('track_mbid_flag', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
289 290 291
    Column('track_mbid_id', Integer, ForeignKey('track_mbid.id'), nullable=False),
    Column('account_id', Integer, ForeignKey('account.id'), nullable=False),
    Column('handled', Boolean, default=False, server_default=sql.false(), nullable=False),
292
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
293 294
)

295
track_puid = Table('track_puid', metadata,
Lukáš Lalinský's avatar
Lukáš Lalinský committed
296 297
    Column('track_id', Integer, ForeignKey('track.id'), nullable=False),
    Column('puid', UUID, nullable=False, index=True),
298
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
299
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
300
    Column('submission_count', Integer, nullable=False),
301
    Index('track_puid_idx_uniq', 'track_id', 'puid', unique=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
302 303
)

304 305
track_puid_source = Table('track_puid_source', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
306
    Column('track_puid_id', Integer, ForeignKey('track_puid.id'), nullable=False),
307
    Column('submission_id', Integer, nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
308
    Column('source_id', Integer, ForeignKey('source.id'), nullable=False),
309
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
310 311 312 313
)

track_meta = Table('track_meta', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
314 315
    Column('track_id', Integer, ForeignKey('track.id'), nullable=False),
    Column('meta_id', Integer, ForeignKey('meta.id'), nullable=False, index=True),
316
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
317
    Column('submission_count', Integer, nullable=False),
318
    Index('track_meta_idx_uniq', 'track_id', 'meta_id', unique=True),
319 320 321 322
)

track_meta_source = Table('track_meta_source', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
323
    Column('track_meta_id', Integer, ForeignKey('track_meta.id'), nullable=False),
324
    Column('submission_id', Integer, nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
325
    Column('source_id', Integer, ForeignKey('source.id'), nullable=False),
326
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
327 328 329 330
)

track_foreignid = Table('track_foreignid', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
331 332
    Column('track_id', Integer, ForeignKey('track.id'), nullable=False),
    Column('foreignid_id', Integer, ForeignKey('foreignid.id'), nullable=False, index=True),
333
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
334
    Column('submission_count', Integer, nullable=False),
335
    Index('track_foreignid_idx_uniq', 'track_id', 'foreignid_id', unique=True),
336 337 338 339
)

track_foreignid_source = Table('track_foreignid_source', metadata,
    Column('id', Integer, primary_key=True),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
340
    Column('track_foreignid_id', Integer, ForeignKey('track_foreignid.id'), nullable=False),
341
    Column('submission_id', Integer, nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
342
    Column('source_id', Integer, ForeignKey('source.id'), nullable=False),
343
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
344 345 346 347 348 349 350
)

recording_acoustid = Table('recording_acoustid', metadata,
    Column('id', Integer, primary_key=True, autoincrement=False),
    Column('acoustid', UUID, nullable=False, index=True),
    Column('recording', UUID, nullable=False),
    Column('disabled', Boolean, default=False, server_default=sql.false(), nullable=False),
351
    Column('created', DateTime(timezone=True), server_default=sql.func.current_timestamp(), nullable=False),
Lukáš Lalinský's avatar
Lukáš Lalinský committed
352 353 354 355 356 357 358 359 360 361
    Column('updated', DateTime(timezone=True)),
    Index('recording_acoustid_idx_uniq', 'recording', 'acoustid', unique=True),
)

mirror_queue = Table('mirror_queue', metadata,
    Column('id', Integer, primary_key=True),
    Column('txid', BigInteger, nullable=False, server_default=sql.func.txid_current()),
    Column('tblname', String, nullable=False),
    Column('op', CHAR(1), CheckConstraint("op = ANY (ARRAY['I'::bpchar, 'U'::bpchar, 'D'::bpchar])"), nullable=False),
    Column('data', Text, nullable=False),
362 363
)

Lukáš Lalinský's avatar
Lukáš Lalinský committed
364
import mbdata.models  # noqa: E402
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
mb_area = mbdata.models.Area.__table__
mb_artist_credit = mbdata.models.ArtistCredit.__table__
mb_artist_credit_name = mbdata.models.ArtistCreditName.__table__
mb_artist = mbdata.models.Artist.__table__
mb_iso_3166_1 = mbdata.models.ISO31661.__table__
mb_medium_format = mbdata.models.MediumFormat.__table__
mb_medium = mbdata.models.Medium.__table__
mb_recording_gid_redirect = mbdata.models.RecordingGIDRedirect.__table__
mb_recording = mbdata.models.Recording.__table__
mb_release_group = mbdata.models.ReleaseGroup.__table__
mb_release_group_primary_type = mbdata.models.ReleaseGroupPrimaryType.__table__
mb_release_group_secondary_type_join = mbdata.models.ReleaseGroupSecondaryTypeJoin.__table__
mb_release_group_secondary_type = mbdata.models.ReleaseGroupSecondaryType.__table__
mb_release = mbdata.models.Release.__table__
mb_track = mbdata.models.Track.__table__

# XXX either stop using this or define view models in mbdata
382 383
mb_release_country = Table('release_event', metadata,
    Column('release', Integer, ForeignKey('musicbrainz.release.id')),
384
    Column('country', Integer, ForeignKey('musicbrainz.area.id')),
385 386 387 388 389
    Column('date_year', Integer),
    Column('date_month', Integer),
    Column('date_day', Integer),
    schema='musicbrainz',
)