I'm trying to move data from our QA servers to production (or dev->local, qa->dev, etc.) with the Django dumpdata and loaddata commands.
I've successfully got things exported that have no foreign dependencies, like so:
python manage.py dumpdata --natural-foreign --indent=4 snippets.somemodel
When trying to migrate content-heavy models (with things like users, documents, images attached to them), I get lots of foreign key complaints. This is particularly problematic because users, documents, images are different across all the environments.
I would love to be able to just move the content and ignore things that depend on foreign keys - is that possible?
Related
My account is deactivated by my hosting provider because it got spammed by a bot. I need to uninstall few Joomla installations and I am trying to see only by looking at the database which one is which. They all are names website_jml1, website_jml2.. etc. Which table should I look into to quickly identify installations? In other words - where in DB joomla stores information about website domain, title, name, etc.
To get a list of all separate extension records, have a look in the #__extensions database table. Do bare in mind that each extension may have it's own separate database tables, so if you do plan on removing manually from the database, make sure you remove all associated database tables, along with files/folders from the Joomla directory.
Just on a side note, in future, always ensure you are running the latest version of Joomla, along with the extensions that you have on your site. Outdated extensions can lead to issues like the one you have.
Background:
I am using GitHub to store a ZF2 application.
The database schema + the actual data stored inside the schema are not being stored inside a version control. At the moment I am in development mode, so I have some database dump scripts that I load into the database when I need to. I also tweak entries in the database via phpMyAdmin when I need ongoing granular control for immediate testing purposes. I am also looking into using Doctrire ORM, so my schema will be part of my code via Annotations, and that will be checked into GitHub. Doctrine ORM will generate the actual schema for me, although it is still a separate step in the deployment process. The actual data however, will still be outside of the application and outside of the repository and currently has to be dealt with separately and is not automated.
Goal:
I want to be able to deploy ZF2 application and the database schema, and the data onto Zend Server and have it "just work" in the most automated, least manual way possible.
Question:
What is a recommended, best practice way to deploy every aspect of ZF2 application in the most automated, least manual way possible and have it "just work"? Let's focus on the Development and Testing mode here, as in Production it may be good to have separate deployment steps to protect against accidental live data overwrites.
You can try Phing (http://www.phing.info/) for deploying your PHP application, adjusting directory permissions, running database migrations, running unit tests, etc. I used Phing in couple of my projects with great success.
I've inherited a v 1.0 Django/Python intranet site.
Django normally pushes from the Django code into the database. For say, table definitions (DDL).
Db architects associated with the project have a new database design that they want me to hook up to the site.
That is, I need somehow to pull the DDL defintions from out of the db and into Django code. E.g. some way to generate a new class from a table.
I know a lot of python but much less Django. Any ideas on how this might be done?
Yes, Django can work with pre-existing DB's. Check this out.
Basically, the command you need to pull models from the DB is python manage.py inspectdb > models.py
I've just started using Heroku with Django and it seems great. However, when I change my existing models I'm not sure how to run those changes to the Heroku environment. The syncdb works just fine when adding all new database tables, but how should I modify existing tables?
I found out that Heroku provides psql access only to a dedicated database so that's out of the question. I haven't tried South but it seems like a solution.
So I guess I'm asking how to make database changes with Django and Heroku?
What you are asking for is called "schema migration" or even "schema evolution". Django has some documentation about it on the wiki.
Django's syncdb command does not support that. As a matter of fact, the documentation for syncdb is clear:
Creates the database tables for all apps in INSTALLED_APPS whose
tables have not already been created
Rather, django proposes to use drop the tables manually and then to run syncdb again in the documentation of the deprecated reset command:
You can also use ALTER TABLE or DROP TABLE statements manually.
But fear not, there are many reusable apps to help you with proper schema migrations and hopefully you can pick the one that suits you best. Rather than elaborate in my answer, please let me link an article I wrote about Django schema migration which compares all current solutions.
South works great on Heroku.
I've been messing around with Django and the Django ORM at home, and I've got to say, I feel it is one of the best out there in terms of ease of use.
However, I was wondering if it was possible to use it in "reverse".
Basically what I would like to do is generate Django models from an existing database schema (from a project that doesn't use django and is pretty old).
Is this possible?
Update: the database in question is Oracle
Yes, use the inspectdb command:
http://docs.djangoproject.com/en/dev/ref/django-admin/#inspectdb
inspectdb
Introspects the database tables in the database pointed-to by the DATABASE_NAME setting and outputs a Django model module (a models.py file) to standard output.
Use this if you have a legacy database with which you'd like to use Django. The script will inspect the database and create a model for each table within it.
As you might expect, the created models will have an attribute for every field in the table. Note that inspectdb has a few special cases in its field-name output:
[...]
(Django 1.7.1) Simply running python manage.py inspectdb will create classes for all tables in database and display on console.
$ python manage.py inspectdb
Save this as a file by using standard Unix output redirection:
$ python manage.py inspectdb > models.py
(This works for me with mysql and django 1.9)
I have made a reusable app based on django's inspectdb command utility,
Django Inspectdb Refactor.
This breaks models into different files inside models folder from a existing database.
This helps managing models when they become large in number.
You can install it via pip:
pip install django-inspectdb-refactor
Then register the app in settings.py as inspectdb_refactor
After this you can use it from command line as :
python manage.py inspectdb_refactor --database=your_dbname_defined_in_settings --app=your_app_label
This will successfully create models folder with all the tables as different model files inside your app. For example:
More details can be found here.