laravel php artisan migrate error occured db not creted? - laravel-5.5

when i run php artisan migrate command for creating db table in database then i got this error please tell me. that how to resolve this error.

The error is quite clear. The table already exists. To resolve that, login to your database and drop the table.
DROP TABLE users;

Related

Prisma migration is bad state

We seem to have gotten our prisma migrations into a bad state. When we get the latest code and run
prisma migrate dev
we get
Migration 20210819161149_some_migration failed to apply cleanly to
the shadow database. Error code: P3018 Error: A migration failed to
apply. New migrations cannot be applied before the error is recovered
from. Read more about how to resolve migration issues in a production
database: https://pris.ly/d/migrate-resolve
Migration name: 20210819161149_some_migration
Database error code: 1065
All the migrations in source control do match the ones in the _prisma_migrations table so I'm not sure why it thinks 20210819161149_some_migration failed. There is nothing in the logs column in _prisma_migrations for that record. I think what happened is a developer applied the migration then changed the migration.sql for it after the fact.
Anyway, we followed the steps outlined https://pris.ly/d/migrate-resolve but they don't seem to resolve the issue. It first suggests running
prisma migrate resolve --rolled-back "20210819161149_some_migration"
but that results in
Error: P3012
Migration 20210819161149_some_migration cannot be rolled
back because it is not in a failed state.
So then we tried to mark it as applied
prisma migrate resolve --applied "20210819161149_some_migration"
but that results in this error
Error: P3008
The migration 20210819161149_some_migration is already
recorded as applied in the database.
We also tried running
prisma migrate deploy
Which gives
13 migrations found in prisma/migrations WARNING The following
migrations have been modified since they were applied:
20210819161149_some_migration
but you still get the same issue above when running prisma migrate dev.
Is there any way to get prisma happy again without deleting all the data?
A possible workaround would involve baselining your development database based on your current schema/migration history. You would need a separate backup database and you will lose your existing migration history, but it should retain your data.
Here's what the process would look like
Delete all migration history from your prisma folder as well as the _prisma_migrations table in your database.
Create a new backup database.
Connect the project to your backup database and run prisma migrate dev --name baseline_migration . This will generate a migration matching your current prisma schema.
Connect back to your main Database and baseline the generated migration by running prisma migrate resolve --applied 20210426141759_baseline_migration (The numbers at the beginning of your migration name will differ).
The reason you'd be creating a backup database and running the initial baseline migrations in that backup database is because you don't want to lose the data in your main database. I realize this is not an ideal solution, but it might work if it's very important for you to keep your data while retaining your existing dev workflow.
This article on Adding Prisma Migrate to an existing project is also worth a read.
You can do how it`s described in this short video
https://youtu.be/BIfvmEhbtBE
https://www.prisma.io/docs/reference/api-reference/error-reference this site will provide you the the correct ways of troubleshooting your problem. I got a migration error (P3009) and when i investigate through the generated sql file and found that some syntax issue occured in the generated file and resolved them and fix the migration issue

Django SQLite on Heroku doesn't recognize any of the changed models and throws a "relation doesn't exist" error

I changed the name of several models on Django. Successfully ran makemigrations and migrate. I can interact with the SQLite directly as admin or through requests on localhost.
before changing the tables I had deployed to Heroku and it was working. when I changed the model names and pushed to Heroku (after successfully running on localhost) I get issues. When I login as admin to the site (on Heroku) I can interact with tables like User and Token, but not with the newly updated models. as soon as I click on them I get bellow error. when I click on add to these models, the columns appear but as soon as I hit save I get below error as well.
ProgrammingError at /admin/app_name/model_name/
relation "app_name_model_name" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "app_name_model_name"
I kept the Debug=True to see what's going on otherwise I get "500 Internal Server Error". I have added heroku's site as "ALLOWED_HOSTS".
When I was trying to make the migrations work, I had delete the files on the migration folder. not sure if there is a similar process on Heroku or if I'm missing something else?
By the way I have ran the migration commands using "heroku run bash" too. also, some of the models only had name changes, some had field updates too, but all of them throw the same error on Heroku.
I removed the app entirely from Heroku and recreated. it's working now.

Django: Integrity error installing fixtures

Foreground
Hi. I´m uploading my Django app database to my Heroku production environment. When I try to manage.py loaddata I get the following error:
django.db.utils.IntegrityError: Problem installing fixtures: insert or update in table "catalog_contactos" violates key constraint.
I found this post where someone suggests that first you should load models that are the base for foreign key: related post
Also I found this post that refers to moving a database to another app (the production version for example). Basically it says:
When you backup whole database by using dumpdata command, it will
backup all the database tables
If you use this database dump to load the fresh database(in another
django project), it can be causes IntegrityError (If you loaddata in
same database it works fine)
To fix this problem, make sure to backup the database by excluding
contenttypes and auth.permissions tables
Link to the post
My code
Following that suggestions I do:
python manage.py dumpdata --exclude auth.permission --exclude contenttypes > data.json
Then on the server I run the following code and get the integrity error:
heroku run python manage.py loaddata data.json
Should I dumpdata model by model and loaddata them in a certaing order? Or I´m coding something wrong? Any clues?
Thanks in advance!
Update
Could this "Natural keys" issue be the solutuion? Django serializing objects
When I had integrity error with django/postgreSQL I did DROP TABLE table in postgreSQL.

Django Programming Error while runing server

I am running a GIS application while getting this error. I have attached error snapshot . Can Someone guide where is error ? If need to see code . Let me know which file you need.
Especially the first line of your exception value pretty much says it all.
Column users.parent_id does not exist
The application is trying to access parent.id from the users table from your database, which obviously does not exist. With other words, your database is not sync with the model structure in the source code. Probably all you have to do, is to run the migrations to add all the missing structures or changes to your database.
If you've developed some of the database structures yourself, you have to run the makemigrations command to build the new migration set for your database.
./manage.py makemigrations
If you have created new migration files or if you have installed and integrated modules into your app, you have to apply the migrations to your database.
./manage.py migrations

Graphite Web Error Log, OperationalError: no such table: auth_user

I have a problem with starting graphite web interface, using apache2. I get 500 Internal error, the screenshot of my log is below. I am new to this website and also to this software. My question might be too simple but, I have spent a lot of time on this. Thanks..
error log:
It looks like the database has not yet been created. You can do so by running:
sudo -u _graphite graphite-manage syncdb --noinput
and that should clear up the 500 error. This is a minimum to get started with Graphite, using the SQLite database. It is possible to configure an alternate database in the local_settings.py file, in which case the above command is not necessary. But with the default configuration, which uses SQLite as the back-end, this command should get you past the error.
Source: https://ianunruh.com/2014/05/monitor-everything-part-4.html