I am new to Heroku. I just migrated my django models using south:
sudo heroku run python manage.py migrate
I get the message "Nothing to migrate" in all of my six apps.
Then when I try to visit the website I get the error:
ProgrammingError "column X does not exist".
Everything works fine locally. What should I do, drop the database and recreate it again? If that is the answer, how do I do that on Heroku?
Thanks for you help.
To drop the database on heroku, run:
heroku pg:psql
as per https://devcenter.heroku.com/articles/heroku-postgresql#pg-psql.
Then do:
drop database <database name>;
create database <database name>;
Then you can try and run your migrations again.
Related
I imported my Symfony project on heroku to see how it will be on production. But i got this error:
2022-03-18T13:30:30.230251+00:00 app[web.1]: [18-Mar-2022 13:30:30 UTC] [critical] Uncaught PHP Exception Doctrine\DBAL\Exception\ConnectionException: "An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused" at /app/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php line 103
2022-03-18T13:30:30.230298+00:00 app[web.1]
So it means that they can not connect to my database, it seems normal since the DATABASE_URL in the .env file is for the localhost(phpmyadmin, root, pwd ="", etc). I have seen that we can add add-ons and i tried to add one for database(ClearDB) but they asked for Credit card(but my one is not available now). I am now looking for a database manager so that i can create my database, get the database's parameters(username, password, etc.) and add it to the heroku app so that i can do my migrations and launch the wesbite.
Is this possible, with which software ?
I'm working on a brand new laravel application for learning laravel.
I've done the following (I'm following this tutorial):
Created new application using laravel new test_project_2
Setup the .env file
Created a database called laravel
Run php artisan migrate
This is my .env file:
This is what I get:
As you can see, I can use the "laravel" database perfectly well when I'm logged into Mariadb via terminal. The website also renders absolutely fine. I did run the SQL command - SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE' but I got the message ERROR 1054 (42S22): Unknown column 'laravel' in 'where clause'
Note - I've worked on other dummy laravel projects last week and didn't face any problems, although admittedly I'm not sure if I ran the php artisan migrate command for those (wasn't required, but I might have run it just cause I kept seeing it).
Why is this problem happening?
How do I fix it?
Run the below command and try migrate command
php artisan cache:clear
php artisan config:clear
can you try creating your database with below and then try migration.
mysql -u root -p
create database [DB name];
use [DB name];
Then do migration:
php artisan migrate
Also make sure you have entered correct database name & credential.
Solved this by changing the DB_HOST values from 127.0.0.1 to localhost.
Anyone know why this works? Beats the heck out of me.
I made a Sinatra app and now I'm trying to deploy it to Heroku.
My app works with PostgreSQL database. There is data in my tables that I scraped during development. It is rendered just fine when I run it locally. However, when I deploy my app, my records do not get transferred. I know this behavior is normal, but I can't find how to transfer my records to production (database is set up correctly, you can add content through forms interactively).
This is my environment.rb:
configure :production, :development do
db = URI.parse(ENV['DATABASE_URL'] || 'postgres://localhost/lakesare')
ActiveRecord::Base.establish_connection(
:adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
:host => db.host,
:username => db.user,
:password => db.password,
:database => db.path[1..-1],
:encoding => 'utf8'
)
end
I have tried
heroku pg:push $my_db_name HEROKU_POSTGRESQL_OLIVE_URL
and it ran successfully, but my records are still not present in production db. Did I do something wrong?
I would use seeds.rb kind of thing, but how to configure it in Sinatra?
If you had a seeds file you could do heroku run ruby seeds.rb. That is assuming that the seeds file is in the root of your application. You can run pretty much any command that you can run locally on the heroku servers by prepending it with heroku run.
The only solution that worked for me is to write a few functions that fill up your database, add them to seeds.rb in db folder, deploy this to Heroku and run
heroku run rake db:schema:load
heroku run rake db:seed
To load a database which runs now on the my computer, SQL Server 2012 and Windows, I have installed Git Bash, taps and Heroku.
Now, whenever I wrote the command
heroku db:push --app myapp
it gives the same error
Invalid database ur
I think I miss something, I have not declared which database should be pushed to the Heroku.
Can you help me with this problem ? how can I use heroku db:push, are there any other steps like creating something ? Why I get this error ? Maybe you will say that "have you read documentation or have you searched google?", Yes
EDIT: What I have know is
Local database
Server name Heroku database
Database name application name
username | or windows authentication postgres database
password | username and password
aws address
Should I put/load some file/gem into the Git ?
EDIT 2:
I have test this command but it gives other error.
heroku db:push postgres://localdbUSERNAME:localdbpassword#localdbDATABASENAME/localdbSERVERNAME --app myapp
Error
Failed to connect to database:
Sequel::AdapterNotFound -> LoadError: cannot load such file -- pg
Heroku db:push does not work with SQL Server, it works with MySQL and/or Postgres. You'll need to switch to running one of these database servers, run your migrations/seeds and then use heroku db:push to push your local database to Herokul
I have an instance of Django-CMS already running in a production environment. I would like to dump all the data related to the CMS (PAGES and PLUGINS) so that I may load it back into my development environment.
When I do python manage.py dumpdata cms it dumps most of the data, but not all of it. None of the content for the plugins is dumped. When I look at the django-cms source, I see that the plugins are organized in a different folder than the rest of the models - I'm sure this has something to do with the behavior of dumpdata.
Does anyone know how they would achieve what I am trying to do?
Thanks for your help/answers!
Django's built in dump and restore commands work well for migrating the contents of the CMS.
To dump the contents of the CMS, you need to include both the cms app as well as each of the plugin types you are using in the dumpdata command, so something like:
manage.py dumpdata cms text picture link file [other plugin types] > cms_export.json
to dump your content (you just need the app name, not the full path, like cms.plugins.text).
Here's an update to the procedure I use:
./manage.py dumpdata >fixtures/all.json
psql
DROP DATABASE [DBNAME];
createdb -T template_postgis [DBNAME]
./manage.py syncdb
psql [DBNAME]
delete from auth_group_permissions; delete from auth_permission; delete from django_admin_log; delete from django_content_type;
If you don't delete the tables above you'll get this error when loading the fixtures:
IntegrityError: duplicate key value violates unique constraint django_content_type_app_label_key
And then:
./manage.py loaddata fixtures/all.json
Philipp
For DjangoCMS 3.0, the syntax is the same but the names of the plugins have all changed. To get all standard plugins:
./manage.py dumpdata cms djangocms_column djangocms_file djangocms_flash djangocms_googlemap djangocms_inherit djangocms_link djangocms_picture djangocms_style djangocms_teaser djangocms_text_ckeditor djangocms_video > cms_export.json
Your dumpdata command only dumps the data for the cms app, but each plugin (cms.plugins.text, cms.plugins.picture, etc.) is its own app, and so needs to be added to the command line.