Giter Club home page Giter Club logo

pg-clone-schema's Introduction

clone_schema

Handles following objects:

  • Tables - structure (indexes, constraints, keys) and optionally, data
  • Views
  • Materialized Views - Structure and data
  • Sequences
  • Functions/Procedures
  • Types (composite and enum)
  • Collations and Domains
  • Triggers
  • Comments
  • Permissions/GRANTs

Arguments:

  • source schema
  • target schema
  • clone with data
  • only generate DDL

You can call function like this to copy schema with data:

select clone_schema('sample', 'sample_clone', true, false);


Alternatively, if you want to copy only schema without data:

select clone_schema('sample', 'sample_clone', false, false);


If you just want to generate the DDL, call it like this:

select clone_schema('sample', 'sample_clone', false, true);

In this case, standard output with "INFO" lines are the generated DDL.


The schema_object_counts.sql file is useful for validating the cloning results. Just run it against source and target schemas to validate object counts after changing default schema name, sample.

Limitations

  • Foreign Tables are not handled at the present time. They must be done manually.
  • DDL only option is not complete since it depends on objects that aren't created yet. See issue#29
  • Functions that reference schema-qualified objects will not clone successfully. The target schema will still reference the source schema in these cases. To use this utility at the present time, you need to remove schema-qualified references within your functions.


Sponsor: http://elephas.io/

Compare cloning with EnterpriseDB's version that only works with their Advanced Server: https://www.enterprisedb.com/edb-docs/d/edb-postgres-advanced-server/user-guides/user-guide/11/EDB_Postgres_Advanced_Server_Guide.1.078.html

pg-clone-schema's People

Contributors

michaeldba avatar denishpatel avatar guignonv avatar fsateler avatar espadav8 avatar leshik avatar gmonfardini avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.