rebuild database from zero django postgres
Step 1: Delete the existing database. Run the following command to drop the existing database in PostgreSQL: dropdb your_database_name
Step 2: Create a new database. Run the following command to create a new database in PostgreSQL: createdb your_database_name
Step 3: Update Django settings. In the settings.py
file of your Django project, update the database configuration to point to the new database you've created. You'll need to update the NAME
, USER
, PASSWORD
, HOST
, and PORT
settings in the DATABASES
section.
Step 4: Make migrations. Run the following command to create initial migrations for your Django app: python manage.py makemigrations
Step 5: Apply migrations. Run the following command to apply the migrations and rebuild your database schema: python manage.py migrate