-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
56 lines (34 loc) · 1.72 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
django-simple-migration is a very simple schema migrator for
Django. Yes, there are a few different existing migration libraries.
I wanted something that let me write a SQL or Python file for each
upgrade and then would run them as needed, keeping track of what
version it was currently on. So I wrote it. This does exactly that
and nothing else.
It's still a work in progress, but is functional and actively used
for at least two production sites.
To install:
-copy the "management" folder into your django project.
-add '<project name>.migration' to the INSTALLED_APPS in your settings.py
-create a 1.sql with your first migration in it.
(there's an example one in there which creates a new table)
-run "python manage.py upgrade -n 1 -e" to perform the upgrade.
That's it. For future migrations, create 2.sql, 3.sql, etc.
You can also have migrations which are python files; simply
create 2.py, 3.py, etc.
-To go back, you can run "python manage.py downgrade" to
perform a downgrade.
This assumes that you've created d_2.sql, d_3.sql, etc. which
does the appropriate actions to undo the migration. It is
recommended (but not required) to write a downgrade for each
upgrade.
Admin App and syncdb configuration
If you want to use the admin app to view the migrations that
have been run on your project, uncomment the admin.py and
replace PROJECT_NAME with your project's name.
Similarly, to use syncdb functionality, replace PROJECT_NAME in
migration/management/__init__.py
This will enable a post syncdb signal so that any time syncdb
is run, the schema will be setup by running all of the upgrades
in /migration/db/ in order. This is useful for dev checkouts, etc.
Questions, thoughts, stones:
@drewvolpe or dv@dewdrops.net