Commit 9329ab0e authored by Brian Guadalupe's avatar Brian Guadalupe

DB migrations

parent 112824b6
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-11-03 04:59
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='album',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('album_name', models.CharField(max_length=64)),
('year', models.DecimalField(decimal_places=0, max_digits=4)),
],
),
migrations.CreateModel(
name='artist',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=64)),
('description', models.TextField()),
],
),
migrations.CreateModel(
name='music_entry',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('order_in_playlist', models.PositiveSmallIntegerField()),
('rating', models.DecimalField(choices=[(0, '1'), (1, '2'), (2, '3'), (3, '4'), (4, '5'), (5, '6'), (6, '7'), (7, '8'), (8, '9'), (9, '10')], decimal_places=0, max_digits=1)),
],
),
migrations.CreateModel(
name='music_playlist',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('playlist_name', models.CharField(max_length=32)),
('is_public', models.BooleanField(default=False)),
],
),
migrations.CreateModel(
name='song',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('song_name', models.TextField()),
('genre', models.CharField(max_length=128)),
('song_length', models.PositiveIntegerField(default=0, null=True)),
('lyrics', models.TextField(null=True)),
('album', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.album')),
('artist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.artist')),
],
),
migrations.CreateModel(
name='tag',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=32)),
('tag', models.ManyToManyField(to='core.music_entry')),
],
),
migrations.CreateModel(
name='user_account',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=64)),
('last_name', models.CharField(max_length=64)),
('email', models.CharField(max_length=64)),
],
),
migrations.AddField(
model_name='music_playlist',
name='user',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.user_account'),
),
migrations.AddField(
model_name='music_entry',
name='playlist',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.music_playlist'),
),
migrations.AddField(
model_name='music_entry',
name='song',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.song'),
),
migrations.AddField(
model_name='album',
name='artist',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.artist'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-11-03 07:46
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
]
operations = [
migrations.RenameModel(
old_name='music_entry',
new_name='MusicEntry',
),
migrations.RenameModel(
old_name='music_playlist',
new_name='MusicPlaylist',
),
migrations.AlterField(
model_name='album',
name='artist',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Artist'),
),
migrations.AlterField(
model_name='musicentry',
name='song',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Song'),
),
migrations.AlterField(
model_name='song',
name='album',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Album'),
),
migrations.AlterField(
model_name='song',
name='artist',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Artist'),
),
]
...@@ -6,33 +6,33 @@ class user_account(models.Model): ...@@ -6,33 +6,33 @@ class user_account(models.Model):
last_name = models.CharField(max_length=64) last_name = models.CharField(max_length=64)
email = models.CharField(max_length=64) email = models.CharField(max_length=64)
class artist(models.Model): class Artist(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
name = models.CharField(max_length=64) name = models.CharField(max_length=64)
description = models.TextField() description = models.TextField()
def __str__(self): def __str__(self):
return self.name return self.name
class album(models.Model): class Album(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
album_name = models.CharField(max_length=64) album_name = models.CharField(max_length=64)
year = models.DecimalField(max_digits=4, decimal_places=0) year = models.DecimalField(max_digits=4, decimal_places=0)
artist = models.ForeignKey(artist) artist = models.ForeignKey(Artist)
def __str__(self): def __str__(self):
return self.album_name return self.album_name
class song(models.Model): class Song(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
song_name = models.TextField() song_name = models.TextField()
genre = models.CharField(max_length=128) genre = models.CharField(max_length=128)
song_length = models.PositiveIntegerField(default=0, null=True) song_length = models.PositiveIntegerField(default=0, null=True)
lyrics = models.TextField(null=True) lyrics = models.TextField(null=True)
artist = models.ForeignKey(artist) album = models.ForeignKey(Album)
album = models.ForeignKey(album) artist = models.ForeignKey(Artist)
def __str__(self): def __str__(self):
return self.song_name return self.song_name
class music_playlist(models.Model): class MusicPlaylist(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
playlist_name = models.CharField(max_length=32) playlist_name = models.CharField(max_length=32)
is_public = models.BooleanField(default=False) is_public = models.BooleanField(default=False)
...@@ -40,7 +40,7 @@ class music_playlist(models.Model): ...@@ -40,7 +40,7 @@ class music_playlist(models.Model):
def __str__(self): def __str__(self):
return self.playlist_name return self.playlist_name
class music_entry(models.Model): class MusicEntry(models.Model):
RATING_CHOICES = ( RATING_CHOICES = (
(0,'1'), (0,'1'),
(1,'2'), (1,'2'),
...@@ -56,12 +56,12 @@ class music_entry(models.Model): ...@@ -56,12 +56,12 @@ class music_entry(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
order_in_playlist = models.PositiveSmallIntegerField() order_in_playlist = models.PositiveSmallIntegerField()
rating = models.DecimalField(max_digits=1, decimal_places=0, choices=RATING_CHOICES) rating = models.DecimalField(max_digits=1, decimal_places=0, choices=RATING_CHOICES)
playlist = models.ForeignKey(music_playlist) playlist = models.ForeignKey(MusicPlaylist)
song = models.ForeignKey(song) song = models.ForeignKey(Song)
class tag(models.Model): class Tag(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
name = models.CharField(max_length=32) name = models.CharField(max_length=32)
tag = models.ManyToManyField(music_entry) tag = models.ManyToManyField(MusicEntry)
def __str__(self): def __str__(self):
return self.name return self.name
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment