PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, April 13, 2022

[FIXED] Why is a Migration not being created in database?

 April 13, 2022     database-migration, django, django-models, migration, postgresql     No comments   

Issue

I connected my app to my database in my settings.py and then ran migrations and my model 0001_initial.py file was created. However, when I try to apply those migrations to the database and create a table, it says no migrations to apply and it doesn't create the table. I don't know why.

Machine 0001_initial.py

class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
    migrations.CreateModel(
        name='Appear',
        fields=[
            ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ('Show', models.CharField(max_length=100)),
            ('Media', models.CharField(blank=True, choices=[('TV', 'TV'), ('Radio', 'Radio'), ('Youtube', 'Youtube'), ('Podcast', 'Podcast')], max_length=30, null=True)),
            ('Episode', models.IntegerField()),
            ('Date', models.DateField(max_length=100)),
            ('Time', models.TimeField()),
            ('Producer', models.CharField(max_length=100)),
            ('Producer_Email', models.EmailField(max_length=254)),
        ],
    ),
]

Why is the table not being created?

settings.py

INSTALLED_APPS = [
'machine.apps.MachineConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms',
}]

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': 'Houston',
    'USER': 'postgres',
    'PASSWORD': '1234',
    'HOST': 'localhost'     
}

I've added my settings.py hopefully this helps.


Solution

my stupid mistake. I was using the master password for the database but on settings.py file. I used the default postgres password that's why it wasn't adding the migration. as soon i changed the password it added it.

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': 'Houston',
    'USER': 'postgres',
    'PASSWORD': '1234',
    'HOST': 'localhost'     
}

I changed it and used my master password that I was using to log into my database and it worked.

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': 'Houston',
    'USER': 'postgres',
    'PASSWORD': 'A*******',
    'HOST': 'localhost'     
}


Answered By - Houston Khanyile
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing