From e2e6661614ec1c8aa0445aad3dcf12887a3584d2 Mon Sep 17 00:00:00 2001 From: gowtham1729 Date: Sun, 10 Dec 2023 18:32:29 +0900 Subject: [PATCH] feat:make migrations --- ...icker_ticker_alter_news_unique_together.py | 21 +++++++++++++++++++ .../backend/django_server/news/models.py | 5 ++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 applications/backend/django_server/news/migrations/0003_alter_ticker_ticker_alter_news_unique_together.py diff --git a/applications/backend/django_server/news/migrations/0003_alter_ticker_ticker_alter_news_unique_together.py b/applications/backend/django_server/news/migrations/0003_alter_ticker_ticker_alter_news_unique_together.py new file mode 100644 index 0000000..20291c7 --- /dev/null +++ b/applications/backend/django_server/news/migrations/0003_alter_ticker_ticker_alter_news_unique_together.py @@ -0,0 +1,21 @@ +# Generated by Django 4.2.7 on 2023-12-10 09:21 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("news", "0002_ticker_news_sentiment"), + ] + + operations = [ + migrations.AlterField( + model_name="ticker", + name="ticker", + field=models.CharField(max_length=100, unique=True), + ), + migrations.AlterUniqueTogether( + name="news", + unique_together={("symbol", "headline")}, + ), + ] diff --git a/applications/backend/django_server/news/models.py b/applications/backend/django_server/news/models.py index 04dad91..0874592 100644 --- a/applications/backend/django_server/news/models.py +++ b/applications/backend/django_server/news/models.py @@ -16,12 +16,15 @@ class News(models.Model): sentiment = models.CharField(max_length=100) + class Meta: + unique_together = ("symbol", "headline") + def __str__(self): return self.headline class Ticker(models.Model): - ticker = models.CharField(max_length=100) + ticker = models.CharField(max_length=100, unique=True) def __str__(self): return self.ticker