Open samodadela opened 2 weeks ago
Note: I removed the 'Create Materialized views' because the materialized view is created in the same place as are normal views. If i don't comment it out, that code will try to create it again and fail because the materialized view already exists.
@samodadela I think I have fixed it. Please try the latest code. Not understanding the 2nd bullet about some views are not being enumerated at all. So you are saying some view defs in the source schema are not being cloned?
Thanks @MichaelDBA I'll give it a spin.
Regarding the 2nd bullet, I was referring to this change:
Some of my views have deptype 'i'
and so are missed by pg-clone-schema.
I tested the latest version.
I had to change the code as in my latest post (add IN ('n', 'i')
, line 2819). Then the cloning of the schema works using 'NODATA
'.
If I clone the schema using 'DATA'
it fails, complaining that the materialized view does not exist. Here are the logs:
db.public> select clone_schema('t_src', 't_clone_schema_data', 'DATA', 'VERBOSE')
clone_schema version 2.2 March 05, 2024
Linux: PostgreSQL 16.4 (Ubuntu 16.4-0ubuntu0.24.04.2) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0, 64-bit
COLLATIONS cloned: 0
DOMAINS cloned: 0
TYPES cloned: 2
SEQUENCES cloned: 154
TABLES cloned: 246
[2024-10-07 10:35:09] [P0001] ERROR: Version: 2.2 March 05, 2024 Action: Mat. Views SearchPath: public oldSP=public newSP=t_logineko Diagnostics: line=PL/pgSQL function clone_schema(text,text,cloneparms[]) line 2029 at EXECUTE. 42P01. relation "t_clone_schema_data.materialized_view" does not exist
[2024-10-07 10:35:09] Where: PL/pgSQL function clone_schema(text,text,cloneparms[]) line 2965 at RAISE
SEQUENCES set: 154
IDENTITIES set: 0
FUNCTIONS cloned: 1
dependent view count=0 for view, view1
dependent view count=0 for view, view2
...
dependent view count=0 for view, view22
VIEWS cloned: 0
MAT VIEWS cloned: 1
Validated it is fixed for NODATA, but still needs to be fixed for DATA case...
@samodadela , please try the latest code, think i got it fixed for NODATA and DATA cases...
Hi,
Found some problems when running
pg-clone-schema
on my project:CREATE OR REPLACE
cannot be used with materialized viewsI made the script 'work' on my schema. But I had to comment out the whole 'Create Materialized views' part - probably loosing a lot of needed functionality. I don't know how to fix it properly.
I'm attaching the modified script. Please compare ignoring white space changes, I messed it up. It was based on rev
164279a
. clone_schema_mod.sql.gz