mirror of
https://github.com/djrobstep/migra.git
synced 2024-10-26 07:00:54 +03:00
replace functions and views where possible
This commit is contained in:
parent
aef9614d34
commit
3e4bfc6abf
@ -1,8 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from sqlbag import raw_execute
|
||||
|
||||
from schemainspect import DBInspector, get_inspector
|
||||
from sqlbag import raw_execute
|
||||
|
||||
from .changes import Changes
|
||||
from .statements import Statements
|
||||
|
@ -13,7 +13,7 @@ homepage = "https://migra.djrobstep.com/"
|
||||
python = "*"
|
||||
sqlbag = "*"
|
||||
six = "*"
|
||||
schemainspect = "== 0.1.1547549341"
|
||||
schemainspect = ">= 0.1.1547903959"
|
||||
psycopg2-binary = { version="*", optional = true }
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
@ -1,19 +1,11 @@
|
||||
drop view if exists "public"."ccc_view3" cascade;
|
||||
drop view if exists "public"."ccc_view3";
|
||||
|
||||
drop function if exists "public"."depends_on_bbb_view2"(t text) cascade;
|
||||
drop function if exists "public"."depends_on_bbb_view2"(t text);
|
||||
|
||||
drop view if exists "public"."ddd_unchanged" cascade;
|
||||
drop view if exists "public"."bbb_view2";
|
||||
|
||||
drop view if exists "public"."bbb_view2" cascade;
|
||||
drop view if exists "public"."aaa_view1";
|
||||
|
||||
drop view if exists "public"."ddd_changed" cascade;
|
||||
|
||||
drop view if exists "public"."aaa_view1" cascade;
|
||||
|
||||
create view "public"."ddd_changed" as SELECT basetable.name,
|
||||
create or replace view "public"."ddd_changed" as SELECT basetable.name,
|
||||
'x'::text AS x
|
||||
FROM basetable;
|
||||
|
||||
|
||||
create view "public"."ddd_unchanged" as SELECT ddd_changed.name
|
||||
FROM ddd_changed;
|
||||
FROM basetable;
|
@ -1,25 +1,17 @@
|
||||
drop view if exists "public"."ccc_view3" cascade;
|
||||
drop view if exists "public"."ccc_view3";
|
||||
|
||||
drop view if exists "public"."ddd" cascade;
|
||||
drop view if exists "public"."ddd";
|
||||
|
||||
drop function if exists "public"."depends_on_bbb_view2"(t text) cascade;
|
||||
drop function if exists "public"."depends_on_bbb_view2"(t text);
|
||||
|
||||
drop view if exists "public"."eee" cascade;
|
||||
drop view if exists "public"."eee";
|
||||
|
||||
drop function if exists "public"."fff"(t text) cascade;
|
||||
drop function if exists "public"."fff"(t text);
|
||||
|
||||
drop view if exists "public"."ddd_unchanged" cascade;
|
||||
drop view if exists "public"."bbb_view2";
|
||||
|
||||
drop view if exists "public"."bbb_view2" cascade;
|
||||
drop view if exists "public"."aaa_view1";
|
||||
|
||||
drop view if exists "public"."ddd_changed" cascade;
|
||||
|
||||
drop view if exists "public"."aaa_view1" cascade;
|
||||
|
||||
create view "public"."ddd_changed" as SELECT basetable.name,
|
||||
create or replace view "public"."ddd_changed" as SELECT basetable.name,
|
||||
'x'::text AS x
|
||||
FROM basetable;
|
||||
|
||||
|
||||
create view "public"."ddd_unchanged" as SELECT ddd_changed.name
|
||||
FROM ddd_changed;
|
||||
|
@ -1,4 +1,4 @@
|
||||
drop view if exists "x"."q" cascade;
|
||||
drop view if exists "x"."q";
|
||||
|
||||
drop table "x"."data";
|
||||
|
||||
@ -8,11 +8,11 @@ create table "x"."t_data" (
|
||||
);
|
||||
|
||||
|
||||
create view "x"."data" as SELECT t_data.id,
|
||||
create or replace view "x"."data" as SELECT t_data.id,
|
||||
t_data.name
|
||||
FROM x.t_data;
|
||||
|
||||
|
||||
create view "x"."q" as SELECT data.id,
|
||||
create or replace view "x"."q" as SELECT data.id,
|
||||
data.name
|
||||
FROM x.data;
|
||||
|
@ -36,11 +36,9 @@ drop index if exists "public"."products_x_idx";
|
||||
|
||||
drop index if exists "public"."products_x_key";
|
||||
|
||||
drop function if exists "public"."changed"(i integer, t text[]) cascade;
|
||||
drop materialized view if exists "public"."matvvv";
|
||||
|
||||
drop materialized view if exists "public"."matvvv" cascade;
|
||||
|
||||
drop view if exists "public"."vvv" cascade;
|
||||
drop view if exists "public"."vvv";
|
||||
|
||||
drop table "public"."aunwanted";
|
||||
|
||||
@ -139,7 +137,7 @@ $function$
|
||||
create materialized view "public"."matvvv" as SELECT 2;
|
||||
|
||||
|
||||
create view "public"."vvv" as SELECT 2;
|
||||
create or replace view "public"."vvv" as SELECT 2;
|
||||
|
||||
|
||||
drop sequence if exists "public"."aunwanted_id_seq";
|
||||
|
@ -36,11 +36,9 @@ drop index if exists "public"."products_x_idx";
|
||||
|
||||
drop index if exists "public"."products_x_key";
|
||||
|
||||
drop function if exists "public"."changed"(i integer, t text[]) cascade;
|
||||
drop materialized view if exists "public"."matvvv";
|
||||
|
||||
drop materialized view if exists "public"."matvvv" cascade;
|
||||
|
||||
drop view if exists "public"."vvv" cascade;
|
||||
drop view if exists "public"."vvv";
|
||||
|
||||
drop table "public"."aunwanted";
|
||||
|
||||
@ -135,7 +133,7 @@ $function$
|
||||
create materialized view "public"."matvvv" as SELECT 2;
|
||||
|
||||
|
||||
create view "public"."vvv" as SELECT 2;
|
||||
create or replace view "public"."vvv" as SELECT 2;
|
||||
|
||||
|
||||
drop sequence if exists "public"."aunwanted_id_seq";
|
||||
|
@ -1,5 +1,5 @@
|
||||
revoke select on table "public"."any_table" from postgres;
|
||||
|
||||
drop view if exists "public"."any_other_view" cascade;
|
||||
drop view if exists "public"."any_other_view";
|
||||
|
||||
grant update on table "public"."any_table" to postgres;
|
||||
|
@ -1,5 +1,5 @@
|
||||
revoke delete on table "public"."any_table" from postgres;
|
||||
|
||||
drop view if exists "public"."any_other_view" cascade;
|
||||
drop view if exists "public"."any_other_view";
|
||||
|
||||
grant update on table "public"."any_table" to postgres;
|
||||
|
@ -1,11 +1,9 @@
|
||||
drop index if exists "goodschema"."t_id_idx";
|
||||
|
||||
drop view if exists "goodschema"."v" cascade;
|
||||
|
||||
drop type "goodschema"."sdfasdfasdf";
|
||||
|
||||
create type "goodschema"."sdfasdfasdf" as enum ('not shipped', 'shipped', 'delivered', 'not delivered');
|
||||
|
||||
alter table "goodschema"."t" add column "name" text;
|
||||
|
||||
create view "goodschema"."v" as SELECT 2;
|
||||
create or replace view "goodschema"."v" as SELECT 2;
|
||||
|
@ -3,11 +3,11 @@ from __future__ import unicode_literals
|
||||
import io
|
||||
|
||||
from pytest import raises
|
||||
from schemainspect import get_inspector
|
||||
from sqlbag import S, load_sql_from_file, temporary_database
|
||||
|
||||
from migra import Migration, Statements, UnsafeMigrationException
|
||||
from migra.command import parse_args, run
|
||||
from schemainspect import get_inspector
|
||||
|
||||
SQL = """select 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user