#29882: UDFs are not dumped to the clone MySQL test db
-------------------------------------+-------------------------------------
Reporter: thomazzo | Owner: thomazzo
Type: Uncategorized | Status: assigned
Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Dan Davis):
* cc: Dan Davis (added)
* has_patch: 1 => 0
* type: New feature => Uncategorized
Comment:
thomazzo,
Can you clarify your database OPTIONS settings?
Without any options to force clone/mirror, Django should not preserve the
DDL and data in the database. In the normal mode, Django is not cloning
the database using `mysqldump` - it is dropping and recreating the
database, and then running migrations.
I've created a git repository that verifies this occurs, but it is not a
patch, but an example.
The git repo is https://github.com/danizen/django-review-29882.
If you set it up with mysql 5.7 on ubuntu and create a "djangoreview" user
and "djangoreview" and "test_djangoreview" database to which that user has
all privileges, you should be able to run `./manage.py test` and verify
you get:
{{{
django.db.utils.OperationalError: (1305, 'FUNCTION test_djangoreview.HELLO
does not exist')
----------------------------------------------------------------------
Ran 2 tests in 0.026s
FAILED (errors=1)
Destroying test database for alias 'default'...
}}}
If you want, you could try to get this test to work in isolation by
writing a custom migration as follows:
{{{
./manage.py makemigrations app --empty -n add_hello_function
}}}
Then, edit the migration file created, and use the RunSQL migration
operation to run text from the file `sql/ddl/hello.sql`. This shows how
you can use the django migrations system to manage custom defined SQL.
There are add-on packages that do similar things, but I want to emphasize
that Django core contains the functionality to read SQL files.
If you are using Python 3, I recommend you pathlib to read a file to get
the text to run.
--
Ticket URL: <https://code.djangoproject.com/ticket/29882#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.3a66f5ac3d8a378ec2f8aa82807c4370%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.