proper schema tracking

This commit is contained in:
Robert Lechte 2018-02-21 17:00:25 +11:00
parent 85ca4bc84d
commit 393dc2b7ce
8 changed files with 21 additions and 1 deletions

1
.gitignore vendored
View File

@ -27,6 +27,7 @@ pip-log.txt
.coverage
.tox
nosetests.xml
.pytest_cache
# Translations
*.mo

View File

@ -6,6 +6,7 @@ from functools import partial
from collections import OrderedDict as od
THINGS = [
'schemas',
'enums',
'sequences',
'constraints',

View File

@ -56,6 +56,8 @@ class Migration(object):
self.statements.safe = safety_on
def add_all_changes(self):
self.add(self.changes.schemas(creations_only=True))
self.add(self.changes.extensions(creations_only=True))
self.add(self.changes.enums(creations_only=True, modifications=False))
self.add(self.changes.sequences(creations_only=True))
@ -84,6 +86,8 @@ class Migration(object):
self.add(self.changes.pk_constraints(creations_only=True))
self.add(self.changes.non_pk_constraints(creations_only=True))
self.add(self.changes.schemas(drops_only=True))
@property
def sql(self):
return self.statements.sql

View File

@ -8,7 +8,7 @@ readme = io.open('README.md').read()
setup(
name='migra',
version='1.0.1509328651',
version='1.0.1519192543',
url='https://github.com/djrobstep/migra',
description='Like diff but for PostgreSQL schemas',
long_description=readme,

View File

@ -1,5 +1,8 @@
create extension pg_trgm;
create schema goodschema;
create schema badschema;
CREATE TYPE shipping_status AS ENUM ('not shipped', 'shipped');
CREATE TYPE unwanted_enum AS ENUM ('unwanted', 'not wanted');

View File

@ -1,6 +1,9 @@
create extension hstore;
create extension citext;
create schema goodschema;
create schema evenbetterschema;
CREATE TYPE shipping_status AS ENUM ('not shipped', 'shipped', 'delivered');
CREATE TYPE bug_status AS ENUM ('new', 'open', 'closed');

View File

@ -1,3 +1,5 @@
create schema if not exists "evenbetterschema";
create extension "citext" with schema "public" version '1.4';
create extension "hstore" with schema "public" version '1.4';
@ -148,3 +150,5 @@ alter table "public"."order_items" add constraint "order_items_product_no_fkey"
alter table "public"."products" add constraint "y" CHECK ((price > (0)::numeric));
alter table "public"."products" add constraint "x" CHECK ((price > (10)::numeric));
drop schema if exists "badschema";

View File

@ -1,3 +1,5 @@
create schema if not exists "evenbetterschema";
create extension "citext" with schema "public" version '1.4';
create extension "hstore" with schema "public" version '1.4';
@ -144,3 +146,5 @@ alter table "public"."order_items" add constraint "order_items_product_no_fkey"
alter table "public"."products" add constraint "y" CHECK ((price > (0)::numeric));
alter table "public"."products" add constraint "x" CHECK ((price > (10)::numeric));
drop schema if exists "badschema";