Repository navigation
Add migration #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add migration #126
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a765b56
add first migration
ericguo202 b30a9df
Merge branch 'preview' of https://github.com/HoagieClub/help into pre…
ericguo202 29ba6f5
fix import and dropped models
ericguo202 b7922a4
turn IntegerField into PositiveIntegerField, make setting db_table co…
ericguo202 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| # Generated by Django 5.2.8 on 2026-09-10 01:35 | ||
|
|
||
| import django.contrib.auth.models | ||
| import django.contrib.auth.validators | ||
| import django.core.validators | ||
| import django.db.models.deletion | ||
| import django.utils.timezone | ||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| initial = True | ||
|
|
||
| dependencies = [ | ||
| ('auth', '0012_alter_user_first_name_max_length'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='Tag', | ||
| fields=[ | ||
| ('id', models.AutoField(primary_key=True, serialize=False)), | ||
| ('name', models.CharField(choices=[('exam prep', 'exam prep'), ('problem set', 'problem set'), ('study tips', 'study tips'), ('concepts', 'concepts'), ('course selection', 'course selection'), ('degree planning', 'degree planning'), ('citation', 'citation'), ('course advice', 'course advice'), ('career', 'career')], max_length=30, unique=True)), | ||
| ], | ||
| options={ | ||
| 'db_table': 'Tag', | ||
| }, | ||
| ), | ||
| migrations.CreateModel( | ||
| name='CustomUser', | ||
| fields=[ | ||
| ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
| ('password', models.CharField(max_length=128, verbose_name='password')), | ||
| ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), | ||
| ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), | ||
| ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), | ||
| ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), | ||
| ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), | ||
| ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), | ||
| ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), | ||
| ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), | ||
| ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), | ||
| ('net_id', models.CharField(db_index=True, max_length=20, unique=True)), | ||
| ('class_year', models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(1900), django.core.validators.MaxValueValidator(2100)])), | ||
| ('hearts', models.PositiveIntegerField(default=0)), | ||
| ('created_at', models.DateTimeField(auto_now_add=True)), | ||
| ('updated_at', models.DateTimeField(auto_now=True)), | ||
| ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')), | ||
| ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')), | ||
| ], | ||
| options={ | ||
| 'db_table': 'User', | ||
| }, | ||
| managers=[ | ||
| ('objects', django.contrib.auth.models.UserManager()), | ||
| ], | ||
| ), | ||
| migrations.CreateModel( | ||
| name='Answer', | ||
| fields=[ | ||
| ('id', models.AutoField(primary_key=True, serialize=False)), | ||
| ('text', models.TextField()), | ||
| ('hearts', models.PositiveIntegerField(default=0)), | ||
| ('is_anonymous', models.BooleanField(default=False)), | ||
| ('created_at', models.DateTimeField(auto_now_add=True)), | ||
| ('updated_at', models.DateTimeField(auto_now=True)), | ||
| ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
| ], | ||
| options={ | ||
| 'db_table': 'Answer', | ||
| }, | ||
| ), | ||
| migrations.CreateModel( | ||
| name='Comment', | ||
| fields=[ | ||
| ('id', models.AutoField(primary_key=True, serialize=False)), | ||
| ('text', models.TextField()), | ||
| ('hearts', models.PositiveIntegerField(default=0)), | ||
| ('is_anonymous', models.BooleanField(default=False)), | ||
| ('created_at', models.DateTimeField(auto_now_add=True)), | ||
| ('updated_at', models.DateTimeField(auto_now=True)), | ||
| ('answer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hoagiehelp.answer')), | ||
| ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
| ], | ||
| options={ | ||
| 'db_table': 'Comment', | ||
| }, | ||
| ), | ||
| migrations.CreateModel( | ||
| name='Question', | ||
| fields=[ | ||
| ('id', models.AutoField(primary_key=True, serialize=False)), | ||
| ('title', models.CharField(max_length=255)), | ||
| ('course', models.CharField(blank=True, db_index=True, max_length=100, null=True)), | ||
| ('details', models.TextField()), | ||
| ('create_time', models.DateTimeField(auto_now_add=True)), | ||
| ('last_updated_time', models.DateTimeField(auto_now=True)), | ||
| ('hearts', models.PositiveIntegerField(default=0)), | ||
| ('view', models.PositiveIntegerField(default=0)), | ||
| ('user_is_anonymous', models.BooleanField(default=False)), | ||
| ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
| ('tags', models.ManyToManyField(to='hoagiehelp.tag')), | ||
| ], | ||
| options={ | ||
| 'db_table': 'Question', | ||
| }, | ||
| ), | ||
| migrations.CreateModel( | ||
| name='Notification', | ||
| fields=[ | ||
| ('id', models.AutoField(primary_key=True, serialize=False)), | ||
| ('is_read', models.BooleanField(default=False)), | ||
| ('created_at', models.DateTimeField(auto_now_add=True)), | ||
| ('answer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hoagiehelp.answer')), | ||
| ('comment', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='hoagiehelp.comment')), | ||
| ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
| ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hoagiehelp.question')), | ||
| ], | ||
| options={ | ||
| 'db_table': 'Notification', | ||
| }, | ||
| ), | ||
| migrations.AddField( | ||
| model_name='answer', | ||
| name='question', | ||
| field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hoagiehelp.question'), | ||
| ), | ||
| migrations.CreateModel( | ||
| name='Heart', | ||
| fields=[ | ||
| ('id', models.AutoField(primary_key=True, serialize=False)), | ||
| ('answer', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='hoagiehelp.answer')), | ||
| ('comment', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='hoagiehelp.comment')), | ||
| ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
| ('question', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='hoagiehelp.question')), | ||
| ], | ||
| options={ | ||
| 'db_table': 'Heart', | ||
| 'constraints': [models.UniqueConstraint(condition=models.Q(('question__isnull', False)), fields=('user', 'question'), name='unique_heart_question'), models.UniqueConstraint(condition=models.Q(('answer__isnull', False)), fields=('user', 'answer'), name='unique_heart_answer'), models.UniqueConstraint(condition=models.Q(('comment__isnull', False)), fields=('user', 'comment'), name='unique_heart_comment'), models.CheckConstraint(condition=models.Q(models.Q(('answer__isnull', True), ('comment__isnull', True), ('question__isnull', False)), models.Q(('answer__isnull', False), ('comment__isnull', True), ('question__isnull', True)), models.Q(('answer__isnull', True), ('comment__isnull', False), ('question__isnull', True)), _connector='OR'), name='heart_exactly_one_target')], | ||
| }, | ||
| ), | ||
| migrations.CreateModel( | ||
| name='AnonymousName', | ||
| fields=[ | ||
| ('id', models.AutoField(primary_key=True, serialize=False)), | ||
| ('anonymous_name', models.CharField(max_length=255)), | ||
| ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
| ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hoagiehelp.question')), | ||
| ], | ||
| options={ | ||
| 'db_table': 'AnonymousName', | ||
| 'constraints': [models.UniqueConstraint(fields=('question', 'user'), name='unique_question_user'), models.UniqueConstraint(fields=('question', 'anonymous_name'), name='unique_question_anonymous_name')], | ||
| }, | ||
| ), | ||
| migrations.CreateModel( | ||
| name='StudyGroup', | ||
| fields=[ | ||
| ('id', models.AutoField(primary_key=True, serialize=False)), | ||
| ('title', models.CharField(max_length=255)), | ||
| ('description', models.TextField(blank=True)), | ||
| ('meeting_datetime', models.DateTimeField(db_index=True)), | ||
| ('max_spots', models.PositiveIntegerField(validators=[django.core.validators.MinValueValidator(1)])), | ||
| ('created_at', models.DateTimeField(auto_now_add=True)), | ||
| ('updated_at', models.DateTimeField(auto_now=True)), | ||
| ('leader', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='study_groups_led', to=settings.AUTH_USER_MODEL)), | ||
| ('members', models.ManyToManyField(blank=True, related_name='study_groups_joined', to=settings.AUTH_USER_MODEL)), | ||
| ], | ||
| options={ | ||
| 'db_table': 'StudyGroup', | ||
| 'ordering': ['-created_at'], | ||
| 'constraints': [models.UniqueConstraint(fields=('leader', 'meeting_datetime', 'title'), name='unique_study_group_per_leader')], | ||
| }, | ||
| ), | ||
| ] | ||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,21 @@ | ||
| from .anonymous_name import AnonymousName | ||
| from .answer import Answer | ||
| from .comment import Comment | ||
| from .heart import Heart | ||
| from .notification import Notification | ||
| from .question import Question | ||
| from .studygroup import StudyGroup | ||
| from .tag import Tag | ||
| from .user import CustomUser | ||
|
|
||
| __all__ = [ | ||
| "CustomUser", | ||
| "Question", | ||
| "AnonymousName", | ||
| "Answer", | ||
| "Comment", | ||
| "Tag", | ||
| "CustomUser", | ||
| "Heart", | ||
| "Notification", | ||
| "Question", | ||
| "StudyGroup", | ||
| "AnonymousName", | ||
| "Tag", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's make sure we're setting
db_tablefor all so naming stays consistent. look atAnonymousNameandStudyGrouptoo