mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Added Schema Diff tool to compare two schemas and generate the difference script.
Currently supported objects are Table, View, Materialized View, Function and Procedure. Backend comparison of two schemas implemented by: Akshay Joshi Fixes #3452.
This commit is contained in:
committed by
Akshay Joshi
parent
8b99a33e6e
commit
45f2e35a99
601
web/pgadmin/tools/schema_diff/__init__.py
Normal file
601
web/pgadmin/tools/schema_diff/__init__.py
Normal file
@@ -0,0 +1,601 @@
|
||||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
"""A blueprint module implementing the schema_diff frame."""
|
||||
|
||||
MODULE_NAME = 'schema_diff'
|
||||
|
||||
import simplejson as json
|
||||
import pickle
|
||||
import random
|
||||
|
||||
from flask import Response, session, url_for, request
|
||||
from flask import render_template, current_app as app
|
||||
from flask_security import current_user, login_required
|
||||
from flask_babelex import gettext
|
||||
from pgadmin.utils import PgAdminModule
|
||||
from pgadmin.utils.ajax import make_json_response, bad_request, \
|
||||
make_response as ajax_response, not_implemented
|
||||
from pgadmin.model import Server
|
||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||
from pgadmin.tools.schema_diff.model import SchemaDiffModel
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
from pgadmin.utils.driver import get_driver
|
||||
|
||||
|
||||
class SchemaDiffModule(PgAdminModule):
|
||||
"""
|
||||
class SchemaDiffModule(PgAdminModule)
|
||||
|
||||
A module class for Schema Diff derived from PgAdminModule.
|
||||
"""
|
||||
|
||||
LABEL = "Schema Diff"
|
||||
|
||||
def get_own_menuitems(self):
|
||||
return {}
|
||||
|
||||
def get_own_javascripts(self):
|
||||
return [{
|
||||
'name': 'pgadmin.schema_diff',
|
||||
'path': url_for('schema_diff.index') + "schema_diff",
|
||||
'when': None
|
||||
}]
|
||||
|
||||
def get_panels(self):
|
||||
return []
|
||||
|
||||
def get_exposed_url_endpoints(self):
|
||||
"""
|
||||
Returns:
|
||||
list: URL endpoints for Schema Diff module
|
||||
"""
|
||||
return [
|
||||
'schema_diff.initialize',
|
||||
'schema_diff.panel',
|
||||
'schema_diff.servers',
|
||||
'schema_diff.databases',
|
||||
'schema_diff.schemas',
|
||||
'schema_diff.compare',
|
||||
'schema_diff.poll',
|
||||
'schema_diff.ddl_compare',
|
||||
'schema_diff.connect_server',
|
||||
'schema_diff.connect_database',
|
||||
'schema_diff.get_server',
|
||||
'schema_diff.generate_script'
|
||||
]
|
||||
|
||||
def register_preferences(self):
|
||||
self.preference.register(
|
||||
'display', 'schema_diff_new_browser_tab',
|
||||
gettext("Open in new browser tab"), 'boolean', False,
|
||||
category_label=gettext('Display'),
|
||||
help_str=gettext('If set to True, the Schema Diff '
|
||||
'will be opened in a new browser tab.')
|
||||
)
|
||||
|
||||
|
||||
blueprint = SchemaDiffModule(MODULE_NAME, __name__, static_url_path='/static')
|
||||
|
||||
|
||||
@blueprint.route("/")
|
||||
@login_required
|
||||
def index():
|
||||
return bad_request(
|
||||
errormsg=gettext('This URL cannot be requested directly.')
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/panel/<int:trans_id>/<path:editor_title>',
|
||||
methods=["GET"],
|
||||
endpoint='panel'
|
||||
)
|
||||
def panel(trans_id, editor_title):
|
||||
"""
|
||||
This method calls index.html to render the schema diff.
|
||||
|
||||
Args:
|
||||
editor_title: Title of the editor
|
||||
"""
|
||||
# If title has slash(es) in it then replace it
|
||||
if request.args and request.args['fslashes'] != '':
|
||||
try:
|
||||
fslashesList = request.args['fslashes'].split(',')
|
||||
for idx in fslashesList:
|
||||
idx = int(idx)
|
||||
editor_title = editor_title[:idx] + '/' + editor_title[idx:]
|
||||
except IndexError as e:
|
||||
app.logger.exception(e)
|
||||
|
||||
return render_template(
|
||||
"schema_diff/index.html",
|
||||
_=gettext,
|
||||
trans_id=trans_id,
|
||||
editor_title=editor_title
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route("/schema_diff.js")
|
||||
@login_required
|
||||
def script():
|
||||
"""render the required javascript"""
|
||||
return Response(
|
||||
response=render_template("schema_diff/js/schema_diff.js", _=gettext),
|
||||
status=200,
|
||||
mimetype="application/javascript"
|
||||
)
|
||||
|
||||
|
||||
def check_transaction_status(trans_id):
|
||||
"""
|
||||
This function is used to check the transaction id
|
||||
is available in the session object.
|
||||
|
||||
Args:
|
||||
trans_id:
|
||||
"""
|
||||
|
||||
if 'schemaDiff' not in session:
|
||||
return False, gettext(
|
||||
'Transaction ID not found in the session.'
|
||||
), None, None
|
||||
|
||||
schema_diff_data = session['schemaDiff']
|
||||
|
||||
# Return from the function if transaction id not found
|
||||
if str(trans_id) not in schema_diff_data:
|
||||
return False, gettext(
|
||||
'Transaction ID not found in the session.'
|
||||
), None, None
|
||||
|
||||
# Fetch the object for the specified transaction id.
|
||||
# Use pickle.loads function to get the model object
|
||||
session_obj = schema_diff_data[str(trans_id)]
|
||||
diff_model_obj = pickle.loads(session_obj['diff_model_obj'])
|
||||
|
||||
return True, None, diff_model_obj, session_obj
|
||||
|
||||
|
||||
def update_session_diff_transaction(trans_id, session_obj, diff_model_obj):
|
||||
"""
|
||||
This function is used to update the diff model into the session.
|
||||
:param trans_id:
|
||||
:param session_obj:
|
||||
:param diff_model_obj:
|
||||
:return:
|
||||
"""
|
||||
session_obj['diff_model_obj'] = pickle.dumps(diff_model_obj, -1)
|
||||
|
||||
if 'schemaDiff' in session:
|
||||
schema_diff_data = session['schemaDiff']
|
||||
schema_diff_data[str(trans_id)] = session_obj
|
||||
session['schemaDiff'] = schema_diff_data
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/initialize',
|
||||
methods=["GET"],
|
||||
endpoint="initialize"
|
||||
)
|
||||
@login_required
|
||||
def initialize():
|
||||
"""
|
||||
This function will initialize the schema diff and return the list
|
||||
of all the server's.
|
||||
"""
|
||||
trans_id = None
|
||||
try:
|
||||
# Create a unique id for the transaction
|
||||
trans_id = str(random.randint(1, 9999999))
|
||||
|
||||
if 'schemaDiff' not in session:
|
||||
schema_diff_data = dict()
|
||||
else:
|
||||
schema_diff_data = session['schemaDiff']
|
||||
|
||||
# Use pickle to store the Schema Diff Model which will be used
|
||||
# later by the diff module.
|
||||
schema_diff_data[trans_id] = {
|
||||
'diff_model_obj': pickle.dumps(SchemaDiffModel(), -1)
|
||||
}
|
||||
|
||||
# Store the schema diff dictionary into the session variable
|
||||
session['schemaDiff'] = schema_diff_data
|
||||
|
||||
except Exception as e:
|
||||
app.logger.exception(e)
|
||||
|
||||
return make_json_response(
|
||||
data={'schemaDiffTransId': trans_id})
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/servers',
|
||||
methods=["GET"],
|
||||
endpoint="servers"
|
||||
)
|
||||
@login_required
|
||||
def servers():
|
||||
"""
|
||||
This function will return the list of servers for the specified
|
||||
server id.
|
||||
"""
|
||||
res = []
|
||||
try:
|
||||
"""Return a JSON document listing the server groups for the user"""
|
||||
driver = get_driver(PG_DEFAULT_DRIVER)
|
||||
|
||||
from pgadmin.browser.server_groups.servers import\
|
||||
server_icon_and_background
|
||||
|
||||
for server in Server.query.filter_by(user_id=current_user.id):
|
||||
manager = driver.connection_manager(server.id)
|
||||
conn = manager.connection()
|
||||
connected = conn.connected()
|
||||
|
||||
res.append({
|
||||
"value": server.id,
|
||||
"label": server.name,
|
||||
"image": server_icon_and_background(connected, manager,
|
||||
server),
|
||||
"_id": server.id,
|
||||
"connected": connected,
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
app.logger.exception(e)
|
||||
|
||||
return make_json_response(data=res)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/get_server/<int:sid>/<int:did>',
|
||||
methods=["GET"],
|
||||
endpoint="get_server"
|
||||
)
|
||||
@login_required
|
||||
def get_server(sid, did):
|
||||
"""
|
||||
This function will return the server details for the specified
|
||||
server id.
|
||||
"""
|
||||
try:
|
||||
"""Return a JSON document listing the server groups for the user"""
|
||||
driver = get_driver(PG_DEFAULT_DRIVER)
|
||||
|
||||
server = Server.query.filter_by(id=sid).first()
|
||||
manager = driver.connection_manager(sid)
|
||||
conn = manager.connection(did=did)
|
||||
connected = conn.connected()
|
||||
|
||||
res = {
|
||||
"sid": sid,
|
||||
"name": server.name,
|
||||
"user": server.username,
|
||||
"gid": server.servergroup_id,
|
||||
"type": manager.server_type,
|
||||
"connected": connected,
|
||||
"database": conn.db
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
app.logger.exception(e)
|
||||
|
||||
return make_json_response(data=res)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/server/connect/<int:sid>',
|
||||
methods=["POST"],
|
||||
endpoint="connect_server"
|
||||
)
|
||||
@login_required
|
||||
def connect_server(sid):
|
||||
server = Server.query.filter_by(id=sid).first()
|
||||
view = SchemaDiffRegistry.get_node_view('server')
|
||||
return view.connect(server.servergroup_id, sid)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/database/connect/<int:sid>/<int:did>',
|
||||
methods=["POST"],
|
||||
endpoint="connect_database"
|
||||
)
|
||||
@login_required
|
||||
def connect_database(sid, did):
|
||||
server = Server.query.filter_by(id=sid).first()
|
||||
view = SchemaDiffRegistry.get_node_view('database')
|
||||
return view.connect(server.servergroup_id, sid, did)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/databases/<int:sid>',
|
||||
methods=["GET"],
|
||||
endpoint="databases"
|
||||
)
|
||||
@login_required
|
||||
def databases(sid):
|
||||
"""
|
||||
This function will return the list of databases for the specified
|
||||
server id.
|
||||
"""
|
||||
res = []
|
||||
try:
|
||||
view = SchemaDiffRegistry.get_node_view('database')
|
||||
|
||||
server = Server.query.filter_by(id=sid).first()
|
||||
response = view.nodes(gid=server.servergroup_id, sid=sid)
|
||||
databases = json.loads(response.data)['data']
|
||||
for db in databases:
|
||||
res.append({
|
||||
"value": db['_id'],
|
||||
"label": db['label'],
|
||||
"_id": db['_id'],
|
||||
"connected": db['connected'],
|
||||
"allowConn": db['allowConn'],
|
||||
"image": db['icon'],
|
||||
"canDisconn": db['canDisconn']
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
app.logger.exception(e)
|
||||
|
||||
return make_json_response(data=res)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/schemas/<int:sid>/<int:did>',
|
||||
methods=["GET"],
|
||||
endpoint="schemas"
|
||||
)
|
||||
@login_required
|
||||
def schemas(sid, did):
|
||||
"""
|
||||
This function will return the list of schemas for the specified
|
||||
server id and database id.
|
||||
"""
|
||||
res = []
|
||||
try:
|
||||
view = SchemaDiffRegistry.get_node_view('schema')
|
||||
server = Server.query.filter_by(id=sid).first()
|
||||
response = view.nodes(gid=server.servergroup_id, sid=sid, did=did)
|
||||
schemas = json.loads(response.data)['data']
|
||||
for sch in schemas:
|
||||
res.append({
|
||||
"value": sch['_id'],
|
||||
"label": sch['label'],
|
||||
"_id": sch['_id'],
|
||||
"image": sch['icon'],
|
||||
})
|
||||
except Exception as e:
|
||||
app.logger.exception(e)
|
||||
|
||||
return make_json_response(data=res)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/compare/<int:trans_id>/<int:source_sid>/<int:source_did>/'
|
||||
'<int:source_scid>/<int:target_sid>/<int:target_did>/<int:target_scid>',
|
||||
methods=["GET"],
|
||||
endpoint="compare"
|
||||
)
|
||||
@login_required
|
||||
def compare(trans_id, source_sid, source_did, source_scid,
|
||||
target_sid, target_did, target_scid):
|
||||
"""
|
||||
This function will compare the two schemas.
|
||||
"""
|
||||
# Check the transaction and connection status
|
||||
status, error_msg, diff_model_obj, session_obj = \
|
||||
check_transaction_status(trans_id)
|
||||
|
||||
if error_msg == gettext('Transaction ID not found in the session.'):
|
||||
return make_json_response(success=0, errormsg=error_msg, status=404)
|
||||
|
||||
if not check_version_compatibility(source_sid, target_sid):
|
||||
return not_implemented(errormsg=gettext("Version mismatch."))
|
||||
|
||||
comparison_result = []
|
||||
|
||||
diff_model_obj.set_comparison_info("Comparing objects...", 0)
|
||||
update_session_diff_transaction(trans_id, session_obj,
|
||||
diff_model_obj)
|
||||
|
||||
try:
|
||||
all_registered_nodes = SchemaDiffRegistry.get_registered_nodes()
|
||||
node_percent = round(100 / len(all_registered_nodes))
|
||||
total_percent = 0
|
||||
|
||||
for node_name, node_view in all_registered_nodes.items():
|
||||
view = SchemaDiffRegistry.get_node_view(node_name)
|
||||
if hasattr(view, 'compare'):
|
||||
msg = "Comparing " + view.blueprint.COLLECTION_LABEL + " ..."
|
||||
diff_model_obj.set_comparison_info(msg, total_percent)
|
||||
# Update the message and total percentage in session object
|
||||
update_session_diff_transaction(trans_id, session_obj,
|
||||
diff_model_obj)
|
||||
|
||||
res = view.compare(source_sid=source_sid,
|
||||
source_did=source_did,
|
||||
source_scid=source_scid,
|
||||
target_sid=target_sid,
|
||||
target_did=target_did,
|
||||
target_scid=target_scid)
|
||||
|
||||
if res is not None:
|
||||
comparison_result = comparison_result + res
|
||||
total_percent = total_percent + node_percent
|
||||
|
||||
msg = "Successfully compare the specified schemas."
|
||||
total_percent = 100
|
||||
diff_model_obj.set_comparison_info(msg, total_percent)
|
||||
# Update the message and total percentage done in session object
|
||||
update_session_diff_transaction(trans_id, session_obj, diff_model_obj)
|
||||
|
||||
except Exception as e:
|
||||
app.logger.exception(e)
|
||||
|
||||
return make_json_response(data=comparison_result)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/poll/<int:trans_id>', methods=["GET"], endpoint="poll"
|
||||
)
|
||||
@login_required
|
||||
def poll(trans_id):
|
||||
"""
|
||||
This function is used to check the schema comparison is completed or not.
|
||||
:param trans_id:
|
||||
:return:
|
||||
"""
|
||||
|
||||
# Check the transaction and connection status
|
||||
status, error_msg, diff_model_obj, session_obj = \
|
||||
check_transaction_status(trans_id)
|
||||
|
||||
if error_msg == gettext('Transaction ID not found in the session.'):
|
||||
return make_json_response(success=0, errormsg=error_msg, status=404)
|
||||
|
||||
msg, diff_percentage = diff_model_obj.get_comparison_info()
|
||||
|
||||
if diff_percentage == 100:
|
||||
diff_model_obj.set_comparison_info("Comparing objects...", 0)
|
||||
update_session_diff_transaction(trans_id, session_obj,
|
||||
diff_model_obj)
|
||||
|
||||
return make_json_response(data={'compare_msg': msg,
|
||||
'diff_percentage': diff_percentage})
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/generate_script/<int:trans_id>/',
|
||||
methods=["POST"],
|
||||
endpoint="generate_script"
|
||||
)
|
||||
def generate_script(trans_id):
|
||||
"""This function will generate the scripts for the selected objects."""
|
||||
data = request.form if request.form else json.loads(
|
||||
request.data, encoding='utf-8'
|
||||
)
|
||||
|
||||
status, error_msg, diff_model_obj, session_obj = \
|
||||
check_transaction_status(trans_id)
|
||||
|
||||
if error_msg == gettext('Transaction ID not found in the session.'):
|
||||
return make_json_response(success=0, errormsg=error_msg, status=404)
|
||||
|
||||
source_sid = int(data['source_sid'])
|
||||
source_did = int(data['source_did'])
|
||||
source_scid = int(data['source_scid'])
|
||||
target_sid = int(data['target_sid'])
|
||||
target_did = int(data['target_did'])
|
||||
target_scid = int(data['target_scid'])
|
||||
diff_ddl = ''
|
||||
|
||||
for d in data['sel_rows']:
|
||||
node_type = d['node_type']
|
||||
source_oid = int(d['source_oid'])
|
||||
target_oid = int(d['target_oid'])
|
||||
comp_status = d['comp_status']
|
||||
|
||||
view = SchemaDiffRegistry.get_node_view(node_type)
|
||||
if view and hasattr(view, 'ddl_compare') and \
|
||||
comp_status != SchemaDiffModel.COMPARISON_STATUS['identical']:
|
||||
sql = view.ddl_compare(source_sid=source_sid,
|
||||
source_did=source_did,
|
||||
source_scid=source_scid,
|
||||
target_sid=target_sid,
|
||||
target_did=target_did,
|
||||
target_scid=target_scid,
|
||||
source_oid=source_oid,
|
||||
target_oid=target_oid,
|
||||
comp_status=comp_status,
|
||||
generate_script=True)
|
||||
|
||||
diff_ddl += sql['diff_ddl']
|
||||
|
||||
return ajax_response(
|
||||
status=200,
|
||||
response={'diff_ddl': diff_ddl}
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/ddl_compare/<int:trans_id>/<int:source_sid>/<int:source_did>/'
|
||||
'<int:source_scid>/<int:target_sid>/<int:target_did>/<int:target_scid>/'
|
||||
'<int:source_oid>/<int:target_oid>/<node_type>/<comp_status>/',
|
||||
methods=["GET"],
|
||||
endpoint="ddl_compare"
|
||||
)
|
||||
@login_required
|
||||
def ddl_compare(trans_id, source_sid, source_did, source_scid,
|
||||
target_sid, target_did, target_scid, source_oid,
|
||||
target_oid, node_type, comp_status):
|
||||
"""
|
||||
This function is used to compare the specified object and return the
|
||||
DDL comparison.
|
||||
"""
|
||||
# Check the transaction and connection status
|
||||
status, error_msg, diff_model_obj, session_obj = \
|
||||
check_transaction_status(trans_id)
|
||||
|
||||
if error_msg == gettext('Transaction ID not found in the session.'):
|
||||
return make_json_response(success=0, errormsg=error_msg, status=404)
|
||||
|
||||
source_ddl = ''
|
||||
target_ddl = ''
|
||||
diff_ddl = ''
|
||||
|
||||
view = SchemaDiffRegistry.get_node_view(node_type)
|
||||
if view and hasattr(view, 'ddl_compare'):
|
||||
sql = view.ddl_compare(source_sid=source_sid, source_did=source_did,
|
||||
source_scid=source_scid, target_sid=target_sid,
|
||||
target_did=target_did, target_scid=target_scid,
|
||||
source_oid=source_oid, target_oid=target_oid,
|
||||
comp_status=comp_status)
|
||||
return ajax_response(
|
||||
status=200,
|
||||
response={'source_ddl': sql['source_ddl'],
|
||||
'target_ddl': sql['target_ddl'],
|
||||
'diff_ddl': sql['diff_ddl']}
|
||||
)
|
||||
|
||||
msg = gettext('Selected object is not supported for DDL comparison.')
|
||||
|
||||
return ajax_response(
|
||||
status=200,
|
||||
response={'source_ddl': msg,
|
||||
'target_ddl': msg,
|
||||
'diff_ddl': msg
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def check_version_compatibility(sid, tid):
|
||||
"""Check the version compatibility of source and target servers."""
|
||||
|
||||
driver = get_driver(PG_DEFAULT_DRIVER)
|
||||
src_server = Server.query.filter_by(id=sid).first()
|
||||
src_manager = driver.connection_manager(src_server.id)
|
||||
|
||||
tar_server = Server.query.filter_by(id=tid).first()
|
||||
tar_manager = driver.connection_manager(tar_server.id)
|
||||
|
||||
def get_round_val(x):
|
||||
if x < 10000:
|
||||
return x if x % 100 == 0 else x + 100 - x % 100
|
||||
else:
|
||||
return x if x % 10000 == 0 else x + 10000 - x % 10000
|
||||
|
||||
if get_round_val(src_manager.version) == \
|
||||
get_round_val(tar_manager.version):
|
||||
return True
|
||||
|
||||
return False
|
212
web/pgadmin/tools/schema_diff/compare.py
Normal file
212
web/pgadmin/tools/schema_diff/compare.py
Normal file
@@ -0,0 +1,212 @@
|
||||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
"""Schema diff object comparison."""
|
||||
|
||||
import copy
|
||||
|
||||
from flask import render_template
|
||||
from pgadmin.utils.compile_template_name import compile_template_path
|
||||
from pgadmin.utils.driver import get_driver
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
from pgadmin.tools.schema_diff.directory_compare import compare_dictionaries,\
|
||||
directory_diff
|
||||
from pgadmin.tools.schema_diff.model import SchemaDiffModel
|
||||
from abc import abstractmethod
|
||||
|
||||
|
||||
class SchemaDiffObjectCompare():
|
||||
|
||||
keys_to_ignore = ['oid', 'schema']
|
||||
|
||||
@staticmethod
|
||||
def get_schema(sid, did, scid):
|
||||
"""
|
||||
This function will return the schema name.
|
||||
"""
|
||||
|
||||
driver = get_driver(PG_DEFAULT_DRIVER)
|
||||
manager = driver.connection_manager(sid)
|
||||
conn = manager.connection(did=did)
|
||||
|
||||
ver = manager.version
|
||||
server_type = manager.server_type
|
||||
|
||||
# Fetch schema name
|
||||
status, schema_name = conn.execute_scalar(
|
||||
render_template(
|
||||
"/".join(['schemas',
|
||||
'{0}/#{1}#'.format(server_type, ver),
|
||||
'sql/get_name.sql']),
|
||||
conn=conn, scid=scid
|
||||
)
|
||||
)
|
||||
|
||||
return status, schema_name
|
||||
|
||||
def compare(self, **kwargs):
|
||||
"""
|
||||
This function is used to compare all the objects
|
||||
from two different schemas.
|
||||
|
||||
:param kwargs:
|
||||
:return:
|
||||
"""
|
||||
|
||||
source_params = {'sid': kwargs.get('source_sid'),
|
||||
'did': kwargs.get('source_did'),
|
||||
'scid': kwargs.get('source_scid')
|
||||
}
|
||||
|
||||
target_params = {'sid': kwargs.get('target_sid'),
|
||||
'did': kwargs.get('target_did'),
|
||||
'scid': kwargs.get('target_scid')
|
||||
}
|
||||
|
||||
if 'source_tid' in kwargs:
|
||||
source_params['tid'] = kwargs['source_tid']
|
||||
if 'target_tid' in kwargs:
|
||||
target_params['tid'] = kwargs['target_tid']
|
||||
|
||||
source = self.fetch_objects_to_compare(**source_params)
|
||||
|
||||
target = self.fetch_objects_to_compare(**target_params)
|
||||
|
||||
# If both the dict have no items then return None.
|
||||
if not (source or target) or (
|
||||
len(source) <= 0 and len(target) <= 0):
|
||||
return None
|
||||
|
||||
return compare_dictionaries(source, target,
|
||||
self.node_type,
|
||||
self.blueprint.COLLECTION_LABEL,
|
||||
self.keys_to_ignore)
|
||||
|
||||
def ddl_compare(self, **kwargs):
|
||||
"""
|
||||
This function will compare object properties and
|
||||
return the difference of SQL
|
||||
"""
|
||||
|
||||
source = ''
|
||||
target = ''
|
||||
diff = ''
|
||||
comp_status = kwargs.get('comp_status')
|
||||
only_diff = False
|
||||
generate_script = False
|
||||
|
||||
source_params = {'gid': 1,
|
||||
'sid': kwargs.get('source_sid'),
|
||||
'did': kwargs.get('source_did'),
|
||||
'scid': kwargs.get('source_scid'),
|
||||
'oid': kwargs.get('source_oid')
|
||||
}
|
||||
|
||||
target_params = {'gid': 1,
|
||||
'sid': kwargs.get('target_sid'),
|
||||
'did': kwargs.get('target_did'),
|
||||
'scid': kwargs.get('target_scid'),
|
||||
'oid': kwargs.get('target_oid')
|
||||
}
|
||||
|
||||
if 'source_tid' in kwargs:
|
||||
source_params['tid'] = kwargs['source_tid']
|
||||
only_diff = True
|
||||
if 'target_tid' in kwargs:
|
||||
target_params['tid'] = kwargs['target_tid']
|
||||
only_diff = True
|
||||
|
||||
if 'generate_script' in kwargs and kwargs['generate_script']:
|
||||
generate_script = True
|
||||
|
||||
source_params_adv = copy.deepcopy(source_params)
|
||||
target_params_adv = copy.deepcopy(target_params)
|
||||
|
||||
del source_params_adv['gid']
|
||||
del target_params_adv['gid']
|
||||
|
||||
status, target_schema = self.get_schema(kwargs.get('target_sid'),
|
||||
kwargs.get('target_did'),
|
||||
kwargs.get('target_scid')
|
||||
)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=target_schema)
|
||||
|
||||
if comp_status == SchemaDiffModel.COMPARISON_STATUS['source_only']:
|
||||
if not generate_script:
|
||||
source = self.get_sql_from_diff(**source_params)
|
||||
source_params.update({
|
||||
'diff_schema': target_schema
|
||||
})
|
||||
diff = self.get_sql_from_diff(**source_params)
|
||||
|
||||
elif comp_status == SchemaDiffModel.COMPARISON_STATUS['target_only']:
|
||||
if not generate_script:
|
||||
target = self.get_sql_from_diff(**target_params)
|
||||
target_params.update(
|
||||
{'drop_sql': True})
|
||||
diff = self.get_sql_from_diff(**target_params)
|
||||
|
||||
elif comp_status == SchemaDiffModel.COMPARISON_STATUS['different']:
|
||||
source = self.fetch_objects_to_compare(**source_params_adv)
|
||||
target = self.fetch_objects_to_compare(**target_params_adv)
|
||||
|
||||
if not (source or target):
|
||||
return None
|
||||
|
||||
diff_dict = directory_diff(source,
|
||||
target,
|
||||
ignore_keys=self.keys_to_ignore,
|
||||
difference={}
|
||||
)
|
||||
|
||||
diff_dict.update(self.parce_acl(source, target))
|
||||
|
||||
if not generate_script:
|
||||
source = self.get_sql_from_diff(**source_params)
|
||||
target = self.get_sql_from_diff(**target_params)
|
||||
|
||||
target_params.update(
|
||||
{'data': diff_dict})
|
||||
diff = self.get_sql_from_diff(**target_params)
|
||||
else:
|
||||
source = self.get_sql_from_diff(**source_params)
|
||||
target = self.get_sql_from_diff(**target_params)
|
||||
|
||||
if only_diff:
|
||||
return diff
|
||||
|
||||
return {'source_ddl': source,
|
||||
'target_ddl': target,
|
||||
'diff_ddl': diff
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def parce_acl(source, target):
|
||||
key = 'acl'
|
||||
|
||||
if 'datacl' in source:
|
||||
key = 'datacl'
|
||||
elif 'relacl' in source:
|
||||
key = 'relacl'
|
||||
|
||||
tmp_source = source[key] if\
|
||||
key in source and source[key] is not None else []
|
||||
tmp_target = copy.deepcopy(target[key]) if\
|
||||
key in target and target[key] is not None else []
|
||||
|
||||
diff = {'added': [], 'deleted': []}
|
||||
for acl in tmp_source:
|
||||
if acl in tmp_target:
|
||||
tmp_target.remove(acl)
|
||||
elif acl not in tmp_target:
|
||||
diff['added'].append(acl)
|
||||
diff['deleted'] = tmp_target
|
||||
|
||||
return {key: diff}
|
279
web/pgadmin/tools/schema_diff/directory_compare.py
Normal file
279
web/pgadmin/tools/schema_diff/directory_compare.py
Normal file
@@ -0,0 +1,279 @@
|
||||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
"""Directory comparison"""
|
||||
|
||||
import copy
|
||||
from pgadmin.tools.schema_diff.model import SchemaDiffModel
|
||||
|
||||
count = 1
|
||||
|
||||
|
||||
def compare_dictionaries(source_dict, target_dict, node, node_label,
|
||||
ignore_keys=None):
|
||||
"""
|
||||
This function will compare the two dictionaries.
|
||||
|
||||
:param source_dict: First Dictionary
|
||||
:param target_dict: Second Dictionary
|
||||
:param node: node type
|
||||
:param ignore_keys: List of keys that will be ignored while comparing
|
||||
:return:
|
||||
"""
|
||||
|
||||
dict1 = copy.deepcopy(source_dict)
|
||||
dict2 = copy.deepcopy(target_dict)
|
||||
|
||||
# Find the duplicate keys in both the dictionaries
|
||||
dict1_keys = set(dict1.keys())
|
||||
dict2_keys = set(dict2.keys())
|
||||
intersect_keys = dict1_keys.intersection(dict2_keys)
|
||||
|
||||
# Keys that are available in source and missing in target.
|
||||
source_only = []
|
||||
added = dict1_keys - dict2_keys
|
||||
global count
|
||||
for item in added:
|
||||
source_only.append({
|
||||
'id': count,
|
||||
'type': node,
|
||||
'label': node_label,
|
||||
'title': item,
|
||||
'oid': source_dict[item]['oid'],
|
||||
'status': SchemaDiffModel.COMPARISON_STATUS['source_only']
|
||||
})
|
||||
count += 1
|
||||
|
||||
target_only = []
|
||||
# Keys that are available in target and missing in source.
|
||||
removed = dict2_keys - dict1_keys
|
||||
for item in removed:
|
||||
target_only.append({
|
||||
'id': count,
|
||||
'type': node,
|
||||
'label': node_label,
|
||||
'title': item,
|
||||
'oid': target_dict[item]['oid'],
|
||||
'status': SchemaDiffModel.COMPARISON_STATUS['target_only']
|
||||
})
|
||||
count += 1
|
||||
|
||||
# Compare the values of duplicates keys.
|
||||
identical = []
|
||||
different = []
|
||||
for key in intersect_keys:
|
||||
# ignore the keys if available.
|
||||
for ig_key in ignore_keys:
|
||||
if ig_key in dict1[key]:
|
||||
dict1[key].pop(ig_key)
|
||||
if ig_key in dict2[key]:
|
||||
dict2[key].pop(ig_key)
|
||||
|
||||
# Recursively Compare the two dictionary
|
||||
if are_dictionaries_identical(dict1[key], dict2[key], ignore_keys):
|
||||
identical.append({
|
||||
'id': count,
|
||||
'type': node,
|
||||
'label': node_label,
|
||||
'title': key,
|
||||
'oid': source_dict[key]['oid'],
|
||||
'source_oid': source_dict[key]['oid'],
|
||||
'target_oid': target_dict[key]['oid'],
|
||||
'status': SchemaDiffModel.COMPARISON_STATUS['identical']
|
||||
})
|
||||
else:
|
||||
different.append({
|
||||
'id': count,
|
||||
'type': node,
|
||||
'label': node_label,
|
||||
'title': key,
|
||||
'oid': source_dict[key]['oid'],
|
||||
'source_oid': source_dict[key]['oid'],
|
||||
'target_oid': target_dict[key]['oid'],
|
||||
'status': SchemaDiffModel.COMPARISON_STATUS['different']
|
||||
})
|
||||
count += 1
|
||||
|
||||
return source_only + target_only + different + identical
|
||||
|
||||
|
||||
def are_lists_identical(source_list, target_list, ignore_keys):
|
||||
"""
|
||||
This function is used to compare two list.
|
||||
:param source_list:
|
||||
:param target_list:
|
||||
:return:
|
||||
"""
|
||||
if source_list is None or target_list is None or \
|
||||
len(source_list) != len(target_list):
|
||||
return False
|
||||
else:
|
||||
for index in range(len(source_list)):
|
||||
# Check the type of the value if it is an dictionary then
|
||||
# call are_dictionaries_identical() function.
|
||||
if type(source_list[index]) is dict:
|
||||
if not are_dictionaries_identical(source_list[index],
|
||||
target_list[index],
|
||||
ignore_keys):
|
||||
return False
|
||||
else:
|
||||
if source_list[index] != target_list[index]:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def are_dictionaries_identical(source_dict, target_dict, ignore_keys):
|
||||
"""
|
||||
This function is used to recursively compare two dictionaries with
|
||||
same keys.
|
||||
:param source_dict:
|
||||
:param target_dict:
|
||||
:return:
|
||||
"""
|
||||
|
||||
src_keys = set(source_dict.keys())
|
||||
tar_keys = set(target_dict.keys())
|
||||
|
||||
# ignore the keys if available.
|
||||
for ig_key in ignore_keys:
|
||||
if ig_key in src_keys:
|
||||
source_dict.pop(ig_key)
|
||||
if ig_key in target_dict:
|
||||
target_dict.pop(ig_key)
|
||||
|
||||
# Keys that are available in source and missing in target.
|
||||
src_only = src_keys - tar_keys
|
||||
# Keys that are available in target and missing in source.
|
||||
tar_only = tar_keys - src_keys
|
||||
|
||||
# If number of keys are different in source and target then
|
||||
# return False
|
||||
if len(src_only) != len(tar_only):
|
||||
return False
|
||||
else:
|
||||
# If number of keys are same but key is not present in target then
|
||||
# return False
|
||||
for key in src_only:
|
||||
if key not in tar_only:
|
||||
return False
|
||||
|
||||
for key in source_dict.keys():
|
||||
if type(source_dict[key]) is dict:
|
||||
if not are_dictionaries_identical(source_dict[key],
|
||||
target_dict[key], ignore_keys):
|
||||
return False
|
||||
elif type(source_dict[key]) is list:
|
||||
if not are_lists_identical(source_dict[key], target_dict[key],
|
||||
ignore_keys):
|
||||
return False
|
||||
else:
|
||||
if source_dict[key] != target_dict[key]:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def directory_diff(source_dict, target_dict, ignore_keys=[], difference={}):
|
||||
"""
|
||||
This function is used to recursively compare two dictionaries and
|
||||
return the difference.
|
||||
The difference is from source to target
|
||||
:param source_dict: source dict
|
||||
:param target_dict: target dict
|
||||
:param ignore_keys: ignore keys to compare
|
||||
"""
|
||||
|
||||
src_keys = set(source_dict.keys())
|
||||
tar_keys = set(target_dict.keys())
|
||||
|
||||
# Keys that are available in source and missing in target.
|
||||
src_only = src_keys - tar_keys
|
||||
# Keys that are available in target and missing in source.
|
||||
tar_only = tar_keys - src_keys
|
||||
|
||||
for key in source_dict.keys():
|
||||
added = []
|
||||
deleted = []
|
||||
updated = []
|
||||
source = None
|
||||
|
||||
# ignore the keys if available.
|
||||
if key in ignore_keys:
|
||||
pass
|
||||
elif key in tar_only:
|
||||
target_only[key] = target_dict[key]
|
||||
# Target only values in deleted list
|
||||
difference[key]['deleted'] = target_dict[key]
|
||||
elif key in src_only:
|
||||
# Source only values in the newly added list
|
||||
if type(source_dict[key]) is list:
|
||||
difference[key] = {}
|
||||
difference[key]['added'] = source_dict[key]
|
||||
elif type(source_dict[key]) is dict:
|
||||
directory_diff(source_dict[key], target_dict[key],
|
||||
ignore_keys, difference)
|
||||
elif type(source_dict[key]) is list:
|
||||
tmp_target = None
|
||||
for index in range(len(source_dict[key])):
|
||||
source = copy.deepcopy(source_dict[key][index])
|
||||
if type(source) is list:
|
||||
# TODO
|
||||
pass
|
||||
elif type(source) is dict:
|
||||
if 'name' in source or 'colname' in source:
|
||||
if type(target_dict[key]) is list and len(
|
||||
target_dict[key]) > 0:
|
||||
tmp = None
|
||||
tmp_target = copy.deepcopy(target_dict[key])
|
||||
for item in tmp_target:
|
||||
if (
|
||||
'name' in item and
|
||||
item['name'] == source['name']
|
||||
) or (
|
||||
'colname' in item and
|
||||
item['colname'] == source['colname']
|
||||
):
|
||||
tmp = copy.deepcopy(item)
|
||||
if tmp and source != tmp:
|
||||
updated.append(copy.deepcopy(source))
|
||||
tmp_target.remove(tmp)
|
||||
elif tmp and source == tmp:
|
||||
tmp_target.remove(tmp)
|
||||
elif tmp is None:
|
||||
added.append(source)
|
||||
else:
|
||||
added.append(source)
|
||||
difference[key] = {}
|
||||
difference[key]['added'] = added
|
||||
difference[key]['changed'] = updated
|
||||
elif target_dict[key] is None or \
|
||||
(type(target_dict[key]) is list and
|
||||
len(target_dict[key]) < index and
|
||||
source != target_dict[key][index]):
|
||||
difference[key] = source
|
||||
elif type(target_dict[key]) is list and\
|
||||
len(target_dict[key]) > index:
|
||||
difference[key] = source
|
||||
|
||||
if type(source) is dict and tmp_target and key in tmp_target and \
|
||||
tmp_target[key] and len(tmp_target[key]) > 0:
|
||||
if type(tmp_target[key]) is list and \
|
||||
type(tmp_target[key][0]) is dict:
|
||||
deleted = deleted + tmp_target[key]
|
||||
else:
|
||||
deleted.append({key: tmp_target[key]})
|
||||
difference[key]['deleted'] = deleted
|
||||
elif tmp_target and type(tmp_target) is list:
|
||||
difference[key]['deleted'] = tmp_target
|
||||
|
||||
else:
|
||||
if source_dict[key] != target_dict[key]:
|
||||
difference[key] = source_dict[key]
|
||||
|
||||
return difference
|
76
web/pgadmin/tools/schema_diff/model.py
Normal file
76
web/pgadmin/tools/schema_diff/model.py
Normal file
@@ -0,0 +1,76 @@
|
||||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
|
||||
class SchemaDiffModel(object):
|
||||
"""
|
||||
SchemaDiffModel
|
||||
"""
|
||||
|
||||
COMPARISON_STATUS = {
|
||||
'source_only': 'Source Only',
|
||||
'target_only': 'Target Only',
|
||||
'different': 'Different',
|
||||
'identical': 'Identical'
|
||||
}
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
"""
|
||||
This method is used to initialize the class and
|
||||
create a proper object name which will be used
|
||||
to fetch the data using namespace name and object name.
|
||||
|
||||
Args:
|
||||
**kwargs : N number of parameters
|
||||
"""
|
||||
self._comparison_result = dict()
|
||||
self._comparison_msg = 'Comparision started...'
|
||||
self._comparison_percentage = 0
|
||||
|
||||
def clear_data(self):
|
||||
"""
|
||||
This function clear the model data.
|
||||
"""
|
||||
self._comparison_result.clear()
|
||||
|
||||
def set_result(self, node_name, compare_result):
|
||||
"""
|
||||
This method set the result of the comparision based on nodes.
|
||||
"""
|
||||
self._comparison_result[node_name] = compare_result
|
||||
|
||||
def get_result(self, node_name=None):
|
||||
"""
|
||||
This function will return the result for the node if specified
|
||||
else return the complete result.
|
||||
:param node_name: Name of the node ex: Database, Schema, etc..
|
||||
:return:
|
||||
"""
|
||||
|
||||
if node_name is not None:
|
||||
return self._comparison_result[node_name]
|
||||
|
||||
return self._comparison_result
|
||||
|
||||
def get_comparison_info(self):
|
||||
"""
|
||||
This function is used to get the comparison information.
|
||||
:return:
|
||||
"""
|
||||
return self._comparison_msg, self._comparison_percentage
|
||||
|
||||
def set_comparison_info(self, msg, percentage):
|
||||
"""
|
||||
This function is used to set the comparison information.
|
||||
:param msg:
|
||||
:param percentage:
|
||||
:return:
|
||||
"""
|
||||
self._comparison_msg = msg
|
||||
self._comparison_percentage = percentage
|
61
web/pgadmin/tools/schema_diff/node_registry.py
Normal file
61
web/pgadmin/tools/schema_diff/node_registry.py
Normal file
@@ -0,0 +1,61 @@
|
||||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
|
||||
class SchemaDiffRegistry(object):
|
||||
"""
|
||||
SchemaDiffRegistry
|
||||
|
||||
It is more of a registry for different type of nodes for schema diff.
|
||||
"""
|
||||
_registered_nodes = dict()
|
||||
|
||||
def __init__(self, node_name, node_view, parent_node='schema'):
|
||||
if node_name not in SchemaDiffRegistry._registered_nodes:
|
||||
SchemaDiffRegistry._registered_nodes[node_name] = {
|
||||
'view': node_view,
|
||||
'parent': parent_node
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def get_registered_nodes(cls, node_name=None, parent_node='schema'):
|
||||
"""
|
||||
This function will return the node's view object if node name
|
||||
is specified or return the complete list of registered nodes.
|
||||
|
||||
:param node_name: Name of the node ex: Database, Schema, etc..
|
||||
:return:
|
||||
"""
|
||||
if node_name is not None:
|
||||
if node_name in cls._registered_nodes:
|
||||
return cls._registered_nodes[node_name]['view']
|
||||
else:
|
||||
return None
|
||||
|
||||
registered_nodes = {}
|
||||
for key, value in cls._registered_nodes.items():
|
||||
if value['parent'] == parent_node:
|
||||
registered_nodes[key] = value['view']
|
||||
|
||||
return registered_nodes
|
||||
|
||||
@classmethod
|
||||
def get_node_view(cls, node_name):
|
||||
"""
|
||||
This function will return the view object for the "nodes"
|
||||
command as per the specified node name.
|
||||
|
||||
:param node_name: Name of the node ex: Database, Schema, etc..
|
||||
:return:
|
||||
"""
|
||||
cmd = {"cmd": "nodes, compare, ddl_compare"}
|
||||
module = SchemaDiffRegistry.get_registered_nodes(node_name)
|
||||
if not module:
|
||||
return None
|
||||
return module(**cmd)
|
189
web/pgadmin/tools/schema_diff/static/css/schema_diff.css
Normal file
189
web/pgadmin/tools/schema_diff/static/css/schema_diff.css
Normal file
@@ -0,0 +1,189 @@
|
||||
.icon-schema-diff {
|
||||
display: inline-block;
|
||||
align-content: center;
|
||||
vertical-align: middle;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
background-size: 20px !important;
|
||||
background-repeat: no-repeat;
|
||||
background-position-x: center;
|
||||
background-position-y: center;
|
||||
background-image: url('../img/compare.svg') !important;
|
||||
}
|
||||
|
||||
.icon-schema-diff-white {
|
||||
display: inline-block;
|
||||
align-content: center;
|
||||
vertical-align: middle;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
background-size: 20px !important;
|
||||
background-repeat: no-repeat;
|
||||
background-position-x: center;
|
||||
background-position-y: center;
|
||||
background-image: url('../img/compare-white.svg') !important;
|
||||
}
|
||||
|
||||
.icon-script {
|
||||
display: inline-block;
|
||||
align-content: center;
|
||||
vertical-align: middle;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
background-size: 20px !important;
|
||||
background-repeat: no-repeat;
|
||||
background-position-x: center;
|
||||
background-position-y: center;
|
||||
background-image: url('../img/script.svg') !important;
|
||||
}
|
||||
|
||||
.really-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
#schema-diff-header {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
#schema-diff-header .control-label {
|
||||
width: 120px !important;
|
||||
padding: 5px 5px !important;
|
||||
}
|
||||
|
||||
.slick-header-column.ui-state-default {
|
||||
height: 32px !important;
|
||||
}
|
||||
|
||||
#schema-diff-grid .grid-header label {
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
margin: auto auto auto 6px;
|
||||
}
|
||||
|
||||
.grid-header .ui-icon {
|
||||
margin: 4px 4px auto 6px;
|
||||
background-color: transparent;
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.slick-row .cell-actions {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Slick.Editors.Text, Slick.Editors.Date */
|
||||
#schema-diff-grid .slick-header > input.editor-text {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
background: transparent;
|
||||
outline: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Slick.Editors.Checkbox */
|
||||
#schema-diff-grid .slick-header > input.editor-checkbox {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.slick-row.selected .cell-selection {
|
||||
background-color: transparent; /* show default selected row background */
|
||||
}
|
||||
|
||||
#schema-diff-grid .slick-header .ui-state-default,
|
||||
#schema-diff-grid .slick-header .ui-widget-content.ui-state-default,
|
||||
#schema-diff-grid .slick-header .ui-widget-header .ui-state-default {
|
||||
background: none;
|
||||
}
|
||||
|
||||
#schema-diff-grid .slick-header .slick-header-column {
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.slick-group-toggle.collapsed, .slick-group-toggle.expanded {
|
||||
background: none !important;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.slick-group-toggle.collapsed::before {
|
||||
font-family: "FontAwesome";
|
||||
content: "\f054";
|
||||
font-size: 0.6rem;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.slick-group-toggle.expanded::before {
|
||||
font-family: "FontAwesome";
|
||||
content: "\f078";
|
||||
font-size: 0.6rem;
|
||||
margin-left: 0rem;
|
||||
}
|
||||
|
||||
.slick-group-toggle {
|
||||
margin-right: 0px !important;
|
||||
height: 11px !important;
|
||||
}
|
||||
|
||||
#schema-diff-ddl-comp .badge .caret {
|
||||
display: inline-block;
|
||||
margin-left: 2px;
|
||||
margin-right: 4px;
|
||||
width: 0.7rem;
|
||||
}
|
||||
|
||||
#schema-diff-ddl-comp .badge .caret::before {
|
||||
font-family: "FontAwesome";
|
||||
content: "\f078";
|
||||
font-size: 0.7rem;
|
||||
margin-left: 0rem;
|
||||
}
|
||||
|
||||
#schema-diff-ddl-comp .badge {
|
||||
font-size: inherit;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
#schema-diff-ddl-comp .accordian-group {
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#ddl_comp_fetching_data.pg-sp-container {
|
||||
height: 100%;
|
||||
bottom: 10px;
|
||||
|
||||
.pg-sp-content {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.ddl-copy {
|
||||
z-index: 10;
|
||||
position: absolute;
|
||||
right: 1px;
|
||||
top: 1px;
|
||||
}
|
||||
|
||||
#schema-diff-grid .pg-panel-message {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
|
||||
#schema-diff-ddl-comp .sql_field_layout {
|
||||
overflow: auto !important;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#schema-diff-ddl-comp .source_ddl, #schema-diff-ddl-comp .target_ddl, #schema-diff-ddl-comp .diff_ddl {
|
||||
height: 300px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.target-buttons {
|
||||
flex-wrap: wrap;
|
||||
max-width: 40% !important;
|
||||
}
|
15
web/pgadmin/tools/schema_diff/static/img/compare-white.svg
Normal file
15
web/pgadmin/tools/schema_diff/static/img/compare-white.svg
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Слой_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 26 26" style="enable-background:new 0 0 26 26;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#FFFFFF;}
|
||||
</style>
|
||||
<path class="st0" d="M21.5,2h-9c-1.1,0-2,0.9-2,2v3h-6c-1.1,0-2,0.9-2,2v13c0,1.1,0.9,2,2,2h8c1.1,0,2-0.9,2-2v-3h7c1.1,0,2-0.9,2-2
|
||||
V4C23.5,2.9,22.6,2,21.5,2z M12.5,14.8H8.9l1-1c0.1-0.1,0.1-0.2,0.1-0.3s0-0.2-0.1-0.3l-0.3-0.3c-0.1-0.1-0.2-0.1-0.3-0.1
|
||||
c-0.1,0-0.2,0-0.3,0.1l-2.3,2.3c-0.1,0.1-0.1,0.2-0.1,0.3c0,0.1,0,0.2,0.1,0.3L9,18.1c0.1,0.1,0.2,0.1,0.3,0.1c0.1,0,0.2,0,0.3-0.1
|
||||
l0.3-0.3c0.1-0.1,0.1-0.2,0.1-0.3c0-0.1,0-0.2-0.1-0.3l-1-1h3.6l0,5.8h-8V9h8L12.5,14.8z M21.5,9.8h-3.6l1-1
|
||||
c0.1-0.1,0.1-0.2,0.1-0.3s0-0.2-0.1-0.3l-0.3-0.3c-0.1-0.1-0.2-0.1-0.3-0.1c-0.1,0-0.2,0-0.3,0.1l-2.3,2.3c-0.1,0.1-0.1,0.2-0.1,0.3
|
||||
c0,0.1,0,0.2,0.1,0.3l2.3,2.3c0.1,0.1,0.2,0.1,0.3,0.1c0.1,0,0.2,0,0.3-0.1l0.3-0.3c0.1-0.1,0.1-0.2,0.1-0.3c0-0.1,0-0.2-0.1-0.3
|
||||
l-1-1h3.6l0,5.8h-7V9c0-1.1-0.9-2-2-2V4h9L21.5,9.8z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
15
web/pgadmin/tools/schema_diff/static/img/compare.svg
Normal file
15
web/pgadmin/tools/schema_diff/static/img/compare.svg
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Слой_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 26 26" style="enable-background:new 0 0 26 26;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#222222;}
|
||||
</style>
|
||||
<path class="st0" d="M21.5,2h-9c-1.1,0-2,0.9-2,2v3h-6c-1.1,0-2,0.9-2,2v13c0,1.1,0.9,2,2,2h8c1.1,0,2-0.9,2-2v-3h7c1.1,0,2-0.9,2-2
|
||||
V4C23.5,2.9,22.6,2,21.5,2z M12.5,14.8H8.9l1-1c0.1-0.1,0.1-0.2,0.1-0.3s0-0.2-0.1-0.3l-0.3-0.3c-0.1-0.1-0.2-0.1-0.3-0.1
|
||||
c-0.1,0-0.2,0-0.3,0.1l-2.3,2.3c-0.1,0.1-0.1,0.2-0.1,0.3c0,0.1,0,0.2,0.1,0.3L9,18.1c0.1,0.1,0.2,0.1,0.3,0.1c0.1,0,0.2,0,0.3-0.1
|
||||
l0.3-0.3c0.1-0.1,0.1-0.2,0.1-0.3c0-0.1,0-0.2-0.1-0.3l-1-1h3.6l0,5.8h-8V9h8L12.5,14.8z M21.5,9.8h-3.6l1-1
|
||||
c0.1-0.1,0.1-0.2,0.1-0.3s0-0.2-0.1-0.3l-0.3-0.3c-0.1-0.1-0.2-0.1-0.3-0.1c-0.1,0-0.2,0-0.3,0.1l-2.3,2.3c-0.1,0.1-0.1,0.2-0.1,0.3
|
||||
c0,0.1,0,0.2,0.1,0.3l2.3,2.3c0.1,0.1,0.2,0.1,0.3,0.1c0.1,0,0.2,0,0.3-0.1l0.3-0.3c0.1-0.1,0.1-0.2,0.1-0.3c0-0.1,0-0.2-0.1-0.3
|
||||
l-1-1h3.6l0,5.8h-7V9c0-1.1-0.9-2-2-2V4h9L21.5,9.8z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
19
web/pgadmin/tools/schema_diff/static/img/script.svg
Normal file
19
web/pgadmin/tools/schema_diff/static/img/script.svg
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#222222;}
|
||||
</style>
|
||||
<g>
|
||||
<path class="st0" d="M40,35V11c0-3.9-3.1-7-7-7H7c-3.9,0-7,3.1-7,7c0,3.1,2.1,5.8,5,6.7V39c0,3.9,3.1,7,7,7h31c3.9,0,7-3.1,7-7v-4
|
||||
H40z M43,42c-0.8,0-1.8-1.4-2.5-3h5C44.9,40.5,43.8,42,43,42z M7,8h19.6C26.2,8.9,26,9.9,26,11c0,1,0.2,2,0.7,3H7c-1.7,0-3-1.3-3-3
|
||||
S5.3,8,7,8z M36.7,42H12c-1.7,0-3-1.3-3-3V18h25v-4h-1c-1.7,0-3-1.3-3-3s1.3-3,3-3s3,1.3,3,3v28C36,40,36.2,41,36.7,42z"/>
|
||||
<rect x="13" y="21" class="st0" width="4" height="4"/>
|
||||
<rect x="19" y="21" class="st0" width="13" height="4"/>
|
||||
<rect x="13" y="28" class="st0" width="4" height="4"/>
|
||||
<rect x="19" y="28" class="st0" width="13" height="4"/>
|
||||
<rect x="13" y="35" class="st0" width="4" height="4"/>
|
||||
<rect x="19" y="35" class="st0" width="13" height="4"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
500
web/pgadmin/tools/schema_diff/static/js/schema_diff.backform.js
Normal file
500
web/pgadmin/tools/schema_diff/static/js/schema_diff.backform.js
Normal file
@@ -0,0 +1,500 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import $ from 'jquery';
|
||||
import Backbone from 'backbone';
|
||||
import Backform from 'pgadmin.backform';
|
||||
import gettext from 'sources/gettext';
|
||||
import clipboard from 'sources/selection/clipboard';
|
||||
|
||||
var formatNode = function (opt) {
|
||||
if (!opt.id) {
|
||||
return opt.text;
|
||||
}
|
||||
|
||||
var optimage = $(opt.element).data('image');
|
||||
|
||||
if (!optimage) {
|
||||
return opt.text;
|
||||
} else {
|
||||
return $('<span></span>').append(
|
||||
$('<span></span>', {
|
||||
class: 'wcTabIcon ' + optimage,
|
||||
})
|
||||
).append($('<span></span>').text(opt.text));
|
||||
}
|
||||
};
|
||||
|
||||
let SchemaDiffSqlControl =
|
||||
Backform.SqlFieldControl.extend({
|
||||
defaults: {
|
||||
label: '',
|
||||
extraClasses: [], // Add default control height
|
||||
helpMessage: null,
|
||||
maxlength: 4096,
|
||||
rows: undefined,
|
||||
copyRequired: false,
|
||||
},
|
||||
|
||||
template: _.template([
|
||||
'<% if (copyRequired) { %><button class="btn btn-secondary ddl-copy d-none">' + gettext('Copy') + '</button> <% } %>',
|
||||
'<div class="pgadmin-controls pg-el-9 pg-el-12 sql_field_layout <%=extraClasses.join(\' \')%>">',
|
||||
' <textarea ',
|
||||
' class="<%=Backform.controlClassName%> " name="<%=name%>"',
|
||||
' maxlength="<%=maxlength%>" placeholder="<%-placeholder%>" <%=disabled ? "disabled" : ""%>',
|
||||
' rows=<%=rows%>',
|
||||
' <%=required ? "required" : ""%>><%-value%></textarea>',
|
||||
' <% if (helpMessage && helpMessage.length) { %>',
|
||||
' <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
|
||||
' <% } %>',
|
||||
'</div>',
|
||||
].join('\n')),
|
||||
initialize: function() {
|
||||
Backform.TextareaControl.prototype.initialize.apply(this, arguments);
|
||||
this.sqlCtrl = null;
|
||||
|
||||
_.bindAll(this, 'onFocus', 'onBlur', 'refreshTextArea', 'copyData',);
|
||||
},
|
||||
render: function() {
|
||||
let obj = Backform.SqlFieldControl.prototype.render.apply(this, arguments);
|
||||
if(this.$el.find('.ddl-copy')) this.$el.find('.ddl-copy').on('click', this.copyData);
|
||||
return obj;
|
||||
},
|
||||
copyData() {
|
||||
event.stopPropagation();
|
||||
clipboard.copyTextToClipboard(this.model.get('diff_ddl'));
|
||||
return false;
|
||||
},
|
||||
onFocus: function() {
|
||||
let $ctrl = this.$el.find('.pgadmin-controls').first(),
|
||||
$copy = this.$el.find('.ddl-copy');
|
||||
if (!$ctrl.hasClass('focused')) $ctrl.addClass('focused');
|
||||
if ($copy.hasClass('d-none')) $copy.removeClass('d-none');
|
||||
|
||||
},
|
||||
onBlur: function() {
|
||||
let $copy = this.$el.find('.ddl-copy');
|
||||
if (!$(event.relatedTarget).hasClass('ddl-copy')) {
|
||||
if (!$copy.hasClass('d-none')) $copy.addClass('d-none');
|
||||
this.$el.find('.pgadmin-controls').first().removeClass('focused');
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
let SchemaDiffSelect2Control =
|
||||
Backform.Select2Control.extend({
|
||||
defaults: _.extend(Backform.Select2Control.prototype.defaults, {
|
||||
url: undefined,
|
||||
transform: undefined,
|
||||
url_with_id: false,
|
||||
select2: {
|
||||
allowClear: true,
|
||||
placeholder: gettext('Select an item...'),
|
||||
width: 'style',
|
||||
templateResult: formatNode,
|
||||
templateSelection: formatNode,
|
||||
},
|
||||
controlsClassName: 'pgadmin-controls pg-el-sm-11 pg-el-12',
|
||||
}),
|
||||
className: function() {
|
||||
return 'pgadmin-controls pg-el-sm-4';
|
||||
},
|
||||
events: {
|
||||
'focus select': 'clearInvalid',
|
||||
'keydown :input': 'processTab',
|
||||
'select2:select': 'onSelect',
|
||||
'select2:selecting': 'beforeSelect',
|
||||
'select2:clear': 'onChange',
|
||||
},
|
||||
template: _.template([
|
||||
'<% if(label == false) {} else {%>',
|
||||
' <label class="<%=Backform.controlLabelClassName%>"><%=label%></label>',
|
||||
'<% }%>',
|
||||
'<div class="<%=controlsClassName%>">',
|
||||
' <select class="<%=Backform.controlClassName%> <%=extraClasses.join(\' \')%>"',
|
||||
' name="<%=name%>" value="<%-value%>" <%=disabled ? "disabled" : ""%>',
|
||||
' <%=required ? "required" : ""%><%= select2.multiple ? " multiple>" : ">" %>',
|
||||
' <%=select2.first_empty ? " <option></option>" : ""%>',
|
||||
' <% for (var i=0; i < options.length; i++) {%>',
|
||||
' <% var option = options[i]; %>',
|
||||
' <option ',
|
||||
' <% if (option.image) { %> data-image=<%=option.image%> <%}%>',
|
||||
' <% if (option.connected) { %> data-connected=connected <%}%>',
|
||||
' value=<%- formatter.fromRaw(option.value) %>',
|
||||
' <% if (option.selected) {%>selected="selected"<%} else {%>',
|
||||
' <% if (!select2.multiple && option.value === rawValue) {%>selected="selected"<%}%>',
|
||||
' <% if (select2.multiple && rawValue && rawValue.indexOf(option.value) != -1){%>selected="selected" data-index="rawValue.indexOf(option.value)"<%}%>',
|
||||
' <%}%>',
|
||||
' <%= disabled ? "disabled" : ""%>><%-option.label%></option>',
|
||||
' <%}%>',
|
||||
' </select>',
|
||||
' <% if (helpMessage && helpMessage.length) { %>',
|
||||
' <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
|
||||
' <% } %>',
|
||||
'</div>',
|
||||
].join('\n')),
|
||||
beforeSelect: function() {
|
||||
var selVal = arguments[0].params.args.data.id;
|
||||
|
||||
if(this.field.get('connect') && this.$el.find('option[value="'+selVal+'"]').attr('data-connected') !== 'connected') {
|
||||
this.field.get('connect').apply(this, [selVal, this.changeIcon.bind(this)]);
|
||||
} else {
|
||||
$(this.$sel).trigger('change');
|
||||
setTimeout(function(){ this.onChange.apply(this); }.bind(this), 200);
|
||||
}
|
||||
},
|
||||
changeIcon: function(data) {
|
||||
let span = this.$el.find('.select2-selection .select2-selection__rendered span.wcTabIcon'),
|
||||
selSpan = this.$el.find('option:selected');
|
||||
|
||||
if (span.hasClass('icon-server-not-connected')) {
|
||||
let icon = (data.icon) ? data.icon : 'icon-pg';
|
||||
span.removeClass('icon-server-not-connected');
|
||||
span.addClass(icon);
|
||||
span.attr('data-connected', 'connected');
|
||||
|
||||
selSpan.data().image = icon;
|
||||
selSpan.attr('data-connected', 'connected');
|
||||
|
||||
this.onChange.apply(this);
|
||||
}
|
||||
else if (span.hasClass('icon-database-not-connected')) {
|
||||
let icon = (data.icon) ? data.icon : 'pg-icon-database';
|
||||
|
||||
span.removeClass('icon-database-not-connected');
|
||||
span.addClass(icon);
|
||||
span.attr('data-connected', 'connected');
|
||||
|
||||
selSpan.removeClass('icon-database-not-connected');
|
||||
selSpan.data().image = icon;
|
||||
selSpan.attr('data-connected', 'connected');
|
||||
|
||||
this.onChange.apply(this);
|
||||
}
|
||||
},
|
||||
onChange: function() {
|
||||
var model = this.model,
|
||||
attrArr = this.field.get('name').split('.'),
|
||||
name = attrArr.shift(),
|
||||
path = attrArr.join('.'),
|
||||
value = this.getValueFromDOM(),
|
||||
changes = {},
|
||||
that = this;
|
||||
|
||||
if (this.model.errorModel instanceof Backbone.Model) {
|
||||
if (_.isEmpty(path)) {
|
||||
this.model.errorModel.unset(name);
|
||||
} else {
|
||||
var nestedError = this.model.errorModel.get(name);
|
||||
if (nestedError) {
|
||||
this.keyPathSetter(nestedError, path, null);
|
||||
this.model.errorModel.set(name, nestedError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changes[name] = _.isEmpty(path) ? value : _.clone(model.get(name)) || {};
|
||||
|
||||
if (!_.isEmpty(path)) that.keyPathSetter(changes[name], path, value);
|
||||
that.stopListening(that.model, 'change:' + name, that.render);
|
||||
model.set(changes);
|
||||
that.listenTo(that.model, 'change:' + name, that.render);
|
||||
|
||||
},
|
||||
render: function() {
|
||||
/*
|
||||
* Initialization from the original control.
|
||||
*/
|
||||
this.fetchData();
|
||||
return Backform.Select2Control.prototype.render.apply(this, arguments);
|
||||
|
||||
},
|
||||
fetchData: function() {
|
||||
/*
|
||||
* We're about to fetch the options required for this control.
|
||||
*/
|
||||
var self = this,
|
||||
url = self.field.get('url'),
|
||||
m = self.model;
|
||||
|
||||
url = _.isFunction(url) ? url.apply(m) : url;
|
||||
|
||||
if (url && self.field.get('deps')) {
|
||||
url = url.replace('sid', m.get(self.field.get('deps')[0]));
|
||||
}
|
||||
|
||||
// Hmm - we found the url option.
|
||||
// That means - we needs to fetch the options from that node.
|
||||
if (url) {
|
||||
var data;
|
||||
|
||||
m.trigger('pgadmin:view:fetching', m, self.field);
|
||||
$.ajax({
|
||||
async: false,
|
||||
url: url,
|
||||
})
|
||||
.done(function(res) {
|
||||
/*
|
||||
* We will cache this data for short period of time for avoiding
|
||||
* same calls.
|
||||
*/
|
||||
data = res.data;
|
||||
})
|
||||
.fail(function() {
|
||||
m.trigger('pgadmin:view:fetch:error', m, self.field);
|
||||
});
|
||||
|
||||
m.trigger('pgadmin:view:fetched', m, self.field);
|
||||
// To fetch only options from cache, we do not need time from 'at'
|
||||
// attribute but only options.
|
||||
//
|
||||
|
||||
/*
|
||||
* Transform the data
|
||||
*/
|
||||
var transform = this.field.get('transform') || self.defaults.transform;
|
||||
if (transform && _.isFunction(transform)) {
|
||||
// We will transform the data later, when rendering.
|
||||
// It will allow us to generate different data based on the
|
||||
// dependencies.
|
||||
self.field.set('options', transform.bind(self, data));
|
||||
} else {
|
||||
self.field.set('options', data);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
let SchemaDiffHeaderView = Backform.Form.extend({
|
||||
label: '',
|
||||
className: function() {
|
||||
return 'pg-el-sm-12 pg-el-md-12 pg-el-lg-12 pg-el-12';
|
||||
},
|
||||
tabPanelClassName: function() {
|
||||
return Backform.tabClassName;
|
||||
},
|
||||
tabIndex: 0,
|
||||
initialize: function(opts) {
|
||||
this.label = opts.label;
|
||||
Backform.Form.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
template: _.template(`
|
||||
<div class="row pgadmin-control-group">
|
||||
<div class="control-label">Select Source</div>
|
||||
<div class="col-6 source row"></div>
|
||||
</div>
|
||||
<div class="row pgadmin-control-group">
|
||||
<div class="control-label">Select Target</div>
|
||||
<div class="col-6 target row"></div>
|
||||
<div class="col-5 target-buttons">
|
||||
<div class="action-btns d-flex">
|
||||
<button class="btn btn-primary mr-auto"><i class="icon-schema-diff-white"></i> ` + gettext('Compare') + `</button>
|
||||
<button id="generate-script" class="btn btn-secondary mr-1" disabled><i class="fa fa-file-code-o sql-icon-lg"></i> ` + gettext('Generate Script') + `</button>
|
||||
<div class="btn-group mr-1" role="group" aria-label="">
|
||||
<button id="btn-filter" type="button" class="btn btn-sm btn-secondary"
|
||||
title=""
|
||||
accesskey=""
|
||||
tabindex="0">
|
||||
<i class="fa fa-filter sql-icon-lg" aria-hidden="true"></i> ` + gettext('Filter') + `
|
||||
</button>
|
||||
<button id="btn-filter-dropdown" type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
|
||||
title=""
|
||||
accesskey=""
|
||||
tabindex="0">
|
||||
</button>` +
|
||||
[
|
||||
'<ul class="dropdown-menu filter">',
|
||||
'<li>',
|
||||
'<a class="dropdown-item" id="btn-identical" href="#" tabindex="0">',
|
||||
'<i class="identical fa fa-check" aria-hidden="true"></i>',
|
||||
'<span> ' + gettext('Identical') + ' </span>',
|
||||
'</a>',
|
||||
'</li>',
|
||||
'<li>',
|
||||
'<a class="dropdown-item" id="btn-differentt" href="#" tabindex="0">',
|
||||
'<i class="different fa fa-check" aria-hidden="true"></i>',
|
||||
'<span> ' + gettext('Different') + ' </span>',
|
||||
'</a>',
|
||||
'</li>',
|
||||
'<li>',
|
||||
'<a class="dropdown-item" id="btn-source-only" href="#" tabindex="0">',
|
||||
'<i class="source-only fa fa-check" aria-hidden="true"></i>',
|
||||
'<span> ' + gettext('Source Only') + ' </span>',
|
||||
'</a>',
|
||||
'</li>',
|
||||
'<li>',
|
||||
'<a class="dropdown-item" id="btn-target-only" href="#" tabindex="0">',
|
||||
'<i class="target-only fa fa-check" aria-hidden="true"></i>',
|
||||
'<span> ' + gettext('Target Only') + ' </span>',
|
||||
'</a>',
|
||||
'</li>',
|
||||
'</ul>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
].join('\n')
|
||||
),
|
||||
render: function() {
|
||||
this.cleanup();
|
||||
|
||||
var controls = this.controls,
|
||||
m = this.model,
|
||||
self = this,
|
||||
idx = (this.tabIndex * 100);
|
||||
|
||||
this.$el.empty();
|
||||
|
||||
$(this.template()).appendTo(this.$el);
|
||||
|
||||
this.fields.each(function(f) {
|
||||
var cntr = new(f.get('control'))({
|
||||
field: f,
|
||||
model: m,
|
||||
dialog: self,
|
||||
tabIndex: idx,
|
||||
});
|
||||
|
||||
if (f.get('group') && f.get('group') == 'source') {
|
||||
self.$el.find('.source').append(cntr.render().$el);
|
||||
}
|
||||
else {
|
||||
self.$el.find('.target').append(cntr.render().$el);
|
||||
}
|
||||
|
||||
controls.push(cntr);
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
remove: function(opts) {
|
||||
if (opts && opts.data) {
|
||||
if (this.model) {
|
||||
if (this.model.reset) {
|
||||
this.model.reset({
|
||||
validate: false,
|
||||
silent: true,
|
||||
stop: true,
|
||||
});
|
||||
}
|
||||
this.model.clear({
|
||||
validate: false,
|
||||
silent: true,
|
||||
stop: true,
|
||||
});
|
||||
delete(this.model);
|
||||
}
|
||||
if (this.errorModel) {
|
||||
this.errorModel.clear({
|
||||
validate: false,
|
||||
silent: true,
|
||||
stop: true,
|
||||
});
|
||||
delete(this.errorModel);
|
||||
}
|
||||
}
|
||||
this.cleanup();
|
||||
Backform.Form.prototype.remove.apply(this, arguments);
|
||||
},
|
||||
});
|
||||
|
||||
let SchemaDiffFooterView = Backform.Form.extend({
|
||||
className: function() {
|
||||
return 'set-group pg-el-12';
|
||||
},
|
||||
tabPanelClassName: function() {
|
||||
return Backform.tabClassName;
|
||||
},
|
||||
legendClass: 'badge',
|
||||
contentClass: Backform.accordianContentClassName,
|
||||
template: {
|
||||
'content': _.template(`
|
||||
<div class="pg-el-sm-12 row <%=contentClass%>">
|
||||
<div class="pg-el-sm-4 ddl-source">Source</div>
|
||||
<div class="pg-el-sm-4 ddl-target">Target</div>
|
||||
<div class="pg-el-sm-4 ddl-diff">Difference
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`),
|
||||
},
|
||||
initialize: function(opts) {
|
||||
this.label = opts.label;
|
||||
Backform.Form.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
render: function() {
|
||||
this.cleanup();
|
||||
|
||||
let m = this.model,
|
||||
$el = this.$el,
|
||||
tmpl = this.template,
|
||||
controls = this.controls,
|
||||
data = {
|
||||
'className': _.result(this, 'className'),
|
||||
'legendClass': _.result(this, 'legendClass'),
|
||||
'contentClass': _.result(this, 'contentClass'),
|
||||
'collapse': _.result(this, 'collapse'),
|
||||
},
|
||||
idx = (this.tabIndex * 100);
|
||||
|
||||
this.$el.empty();
|
||||
|
||||
let el = $((tmpl['content'])(data)).appendTo($el);
|
||||
|
||||
this.fields.each(function(f) {
|
||||
let cntr = new(f.get('control'))({
|
||||
field: f,
|
||||
model: m,
|
||||
dialog: self,
|
||||
tabIndex: idx,
|
||||
name: f.get('name'),
|
||||
});
|
||||
|
||||
if (f.get('group') && f.get('group') == 'ddl-source') {
|
||||
el.find('.ddl-source').append(cntr.render().$el);
|
||||
}
|
||||
else if (f.get('group') && f.get('group') == 'ddl-target') {
|
||||
el.find('.ddl-target').append(cntr.render().$el);
|
||||
}
|
||||
else {
|
||||
el.find('.ddl-diff').append(cntr.render().$el);
|
||||
}
|
||||
controls.push(cntr);
|
||||
});
|
||||
|
||||
let $diff_sc = this.$el.find('.source_ddl'),
|
||||
$diff_tr = this.$el.find('.target_ddl'),
|
||||
$diff = this.$el.find('.diff_ddl'),
|
||||
footer_height = this.$el.parent().height() - 50;
|
||||
$diff_sc.height(footer_height);
|
||||
$diff_sc.css({
|
||||
'height': footer_height + 'px',
|
||||
});
|
||||
$diff_tr.height(footer_height);
|
||||
$diff_tr.css({
|
||||
'height': footer_height + 'px',
|
||||
});
|
||||
$diff.height(footer_height);
|
||||
$diff.css({
|
||||
'height': footer_height + 'px',
|
||||
});
|
||||
|
||||
|
||||
return this;
|
||||
},
|
||||
});
|
||||
export {
|
||||
SchemaDiffSelect2Control,
|
||||
SchemaDiffHeaderView,
|
||||
SchemaDiffFooterView,
|
||||
SchemaDiffSqlControl,
|
||||
};
|
145
web/pgadmin/tools/schema_diff/static/js/schema_diff.js
Normal file
145
web/pgadmin/tools/schema_diff/static/js/schema_diff.js
Normal file
@@ -0,0 +1,145 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
define('pgadmin.schemadiff', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
|
||||
'sources/pgadmin', 'sources/csrf', 'pgadmin.browser.node',
|
||||
], function(
|
||||
gettext, url_for, $, _, pgAdmin, csrfToken
|
||||
) {
|
||||
|
||||
var wcDocker = window.wcDocker,
|
||||
pgBrowser = pgAdmin.Browser;
|
||||
/* Return back, this has been called more than once */
|
||||
if (pgBrowser.SchemaDiff)
|
||||
return pgBrowser.SchemaDiff;
|
||||
|
||||
// Create an Object Restore of pgBrowser class
|
||||
pgBrowser.SchemaDiff = {
|
||||
init: function() {
|
||||
if (this.initialized)
|
||||
return;
|
||||
|
||||
this.initialized = true;
|
||||
csrfToken.setPGCSRFToken(pgAdmin.csrf_token_header, pgAdmin.csrf_token);
|
||||
|
||||
|
||||
// Define the nodes on which the menus to be appear
|
||||
var menus = [{
|
||||
name: 'schema_diff',
|
||||
module: this,
|
||||
applies: ['tools'],
|
||||
callback: 'show_schema_diff_tool',
|
||||
priority: 1,
|
||||
label: gettext('Schema Diff'),
|
||||
enable: true,
|
||||
}];
|
||||
|
||||
pgBrowser.add_menus(menus);
|
||||
|
||||
// Creating a new pgBrowser frame to show the data.
|
||||
var schemaDiffFrameType = new pgBrowser.Frame({
|
||||
name: 'frm_schemadiff',
|
||||
showTitle: true,
|
||||
isCloseable: true,
|
||||
isPrivate: true,
|
||||
url: 'about:blank',
|
||||
});
|
||||
|
||||
let self = this;
|
||||
/* Cache may take time to load for the first time
|
||||
* Keep trying till available
|
||||
*/
|
||||
let cacheIntervalId = setInterval(function() {
|
||||
if(pgBrowser.preference_version() > 0) {
|
||||
self.preferences = pgBrowser.get_preferences_for_module('schema_diff');
|
||||
clearInterval(cacheIntervalId);
|
||||
}
|
||||
},0);
|
||||
|
||||
pgBrowser.onPreferencesChange('schema_diff', function() {
|
||||
self.preferences = pgBrowser.get_preferences_for_module('schema_diff');
|
||||
});
|
||||
|
||||
// Load the newly created frame
|
||||
schemaDiffFrameType.load(pgBrowser.docker);
|
||||
return this;
|
||||
},
|
||||
|
||||
// Callback to draw schema diff for objects
|
||||
show_schema_diff_tool: function() {
|
||||
var self = this,
|
||||
baseUrl = url_for('schema_diff.initialize', null);
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl,
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
})
|
||||
.done(function(res) {
|
||||
self.trans_id = res.data.schemaDiffTransId;
|
||||
res.data.panel_title = 'Schema Diff'; //TODO: Set the panel title
|
||||
// TODO: Following function is used to test the fetching of the
|
||||
// databases this should be moved to server selection event later.
|
||||
self.launch_schema_diff(res.data);
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
self.raise_error_on_fail(gettext('Schema Diff initialize error') , xhr);
|
||||
});
|
||||
},
|
||||
|
||||
launch_schema_diff: function(data) {
|
||||
var panel_title = data.panel_title,
|
||||
trans_id = data.schemaDiffTransId,
|
||||
panel_tooltip = '';
|
||||
|
||||
var url_params = {
|
||||
'trans_id': trans_id,
|
||||
'editor_title': panel_title,
|
||||
},
|
||||
baseUrl = url_for('schema_diff.panel', url_params);
|
||||
|
||||
if (this.preferences.schema_diff_new_browser_tab) {
|
||||
window.open(baseUrl, '_blank');
|
||||
} else {
|
||||
|
||||
var propertiesPanel = pgBrowser.docker.findPanels('properties'),
|
||||
schemaDiffPanel = pgBrowser.docker.addPanel('frm_schemadiff', wcDocker.DOCK.STACKED, propertiesPanel[0]);
|
||||
|
||||
// Set panel title and icon
|
||||
schemaDiffPanel.title('<span title="'+panel_tooltip+'">'+panel_title+'</span>');
|
||||
schemaDiffPanel.icon('icon-schema-diff');
|
||||
schemaDiffPanel.focus();
|
||||
|
||||
var openSchemaDiffURL = function(j) {
|
||||
// add spinner element
|
||||
$(j).data('embeddedFrame').$container.append(pgBrowser.SchemaDiff.spinner_el);
|
||||
setTimeout(function() {
|
||||
var frameInitialized = $(j).data('frameInitialized');
|
||||
if (frameInitialized) {
|
||||
var frame = $(j).data('embeddedFrame');
|
||||
if (frame) {
|
||||
frame.openURL(baseUrl);
|
||||
frame.$container.find('.pg-sp-container').delay(1000).hide(1);
|
||||
}
|
||||
} else {
|
||||
openSchemaDiffURL(j);
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
|
||||
openSchemaDiffURL(schemaDiffPanel);
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
return pgBrowser.SchemaDiff;
|
||||
});
|
38
web/pgadmin/tools/schema_diff/static/js/schema_diff_hook.js
Normal file
38
web/pgadmin/tools/schema_diff/static/js/schema_diff_hook.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
define([
|
||||
'sources/url_for', 'jquery',
|
||||
'sources/pgadmin', 'pgadmin.tools.schema_diff_ui',
|
||||
], function(
|
||||
url_for, $, pgAdmin, SchemaDiffUIModule
|
||||
) {
|
||||
var pgTools = pgAdmin.Tools = pgAdmin.Tools || {};
|
||||
var SchemaDiffUI = SchemaDiffUIModule.default;
|
||||
|
||||
/* Return back, this has been called more than once */
|
||||
if (pgTools.SchemaDiffHook)
|
||||
return pgTools.SchemaDiffHook;
|
||||
|
||||
pgTools.SchemaDiffHook = {
|
||||
load: function(trans_id) {
|
||||
window.onbeforeunload = function() {
|
||||
$.ajax({
|
||||
url: url_for('schemadiff.index') + 'close/'+trans_id,
|
||||
method: 'DELETE',
|
||||
});
|
||||
};
|
||||
|
||||
let schemaUi = new SchemaDiffUI($('#schema-diff-container'), trans_id);
|
||||
schemaUi.render();
|
||||
},
|
||||
};
|
||||
|
||||
return pgTools.SchemaDiffHook;
|
||||
});
|
845
web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js
Normal file
845
web/pgadmin/tools/schema_diff/static/js/schema_diff_ui.js
Normal file
@@ -0,0 +1,845 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import url_for from 'sources/url_for';
|
||||
import $ from 'jquery';
|
||||
import gettext from 'sources/gettext';
|
||||
import Alertify from 'pgadmin.alertifyjs';
|
||||
import Backbone from 'backbone';
|
||||
import Slick from 'sources/../bundle/slickgrid';
|
||||
import pgAdmin from 'sources/pgadmin';
|
||||
import {setPGCSRFToken} from 'sources/csrf';
|
||||
import {generateScript} from 'tools/datagrid/static/js/show_query_tool';
|
||||
import 'pgadmin.sqleditor';
|
||||
import pgWindow from 'sources/window';
|
||||
|
||||
import {SchemaDiffSelect2Control, SchemaDiffHeaderView,
|
||||
SchemaDiffFooterView, SchemaDiffSqlControl} from './schema_diff.backform';
|
||||
|
||||
var wcDocker = window.wcDocker;
|
||||
|
||||
export default class SchemaDiffUI {
|
||||
constructor(container, trans_id) {
|
||||
var self = this;
|
||||
this.$container = container;
|
||||
this.header = null;
|
||||
this.trans_id = trans_id;
|
||||
this.filters = ['Identical', 'Different', 'Source Only', 'Target Only'];
|
||||
this.sel_filters = ['Identical', 'Different', 'Source Only', 'Target Only'];
|
||||
this.dataView = null;
|
||||
this.grid = null,
|
||||
this.selection = {};
|
||||
|
||||
this.model = new Backbone.Model({
|
||||
source_sid: undefined,
|
||||
source_did: undefined,
|
||||
source_scid: undefined,
|
||||
target_sid: undefined,
|
||||
target_did: undefined,
|
||||
target_scid: undefined,
|
||||
source_ddl: undefined,
|
||||
target_ddl: undefined,
|
||||
diff_ddl: undefined,
|
||||
});
|
||||
|
||||
setPGCSRFToken(pgAdmin.csrf_token_header, pgAdmin.csrf_token);
|
||||
|
||||
this.docker = new wcDocker(
|
||||
this.$container, {
|
||||
allowContextMenu: false,
|
||||
allowCollapse: false,
|
||||
loadingClass: 'pg-sp-icon',
|
||||
themePath: url_for('static', {
|
||||
'filename': 'css',
|
||||
}),
|
||||
theme: 'webcabin.overrides.css',
|
||||
}
|
||||
);
|
||||
|
||||
this.header_panel = new pgAdmin.Browser.Panel({
|
||||
name: 'schema_diff_header_panel',
|
||||
showTitle: false,
|
||||
isCloseable: false,
|
||||
isPrivate: true,
|
||||
content: '<div id="schema-diff-header" class="pg-el-container" el="sm"></div><div id="schema-diff-grid" class="pg-el-container" el="sm"></div>',
|
||||
elContainer: true,
|
||||
});
|
||||
|
||||
this.footer_panel = new pgAdmin.Browser.Panel({
|
||||
name: 'schema_diff_footer_panel',
|
||||
title: gettext('DDL Comparison'),
|
||||
isCloseable: false,
|
||||
isPrivate: true,
|
||||
height: '60',
|
||||
content: `<div id="schema-diff-ddl-comp" class="pg-el-container" el="sm">
|
||||
<div id="ddl_comp_fetching_data" class="pg-sp-container schema-diff-busy-fetching d-none">
|
||||
<div class="pg-sp-content">
|
||||
<div class="row">
|
||||
<div class="col-12 pg-sp-icon"></div>
|
||||
</div>
|
||||
<div class="row"><div class="col-12 pg-sp-text">` + gettext('Comparing objects...') + `</div></div>
|
||||
</div>
|
||||
</div></div>`,
|
||||
});
|
||||
|
||||
this.header_panel.load(this.docker);
|
||||
this.footer_panel.load(this.docker);
|
||||
|
||||
|
||||
this.panel_obj = this.docker.addPanel('schema_diff_header_panel', wcDocker.DOCK.TOP, {w:'95%', h:'50%'});
|
||||
this.footer_panel_obj = this.docker.addPanel('schema_diff_footer_panel', wcDocker.DOCK.BOTTOM, this.panel_obj, {w:'95%', h:'50%'});
|
||||
|
||||
self.footer_panel_obj.on(wcDocker.EVENT.VISIBILITY_CHANGED, function() {
|
||||
setTimeout(function() {
|
||||
this.resize_grid();
|
||||
}.bind(self), 200);
|
||||
});
|
||||
|
||||
self.footer_panel_obj.on(wcDocker.EVENT.RESIZE_ENDED, function() {
|
||||
setTimeout(function() {
|
||||
this.resize_panels();
|
||||
}.bind(self), 200);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
raise_error_on_fail(alert_title, xhr) {
|
||||
try {
|
||||
var err = JSON.parse(xhr.responseText);
|
||||
Alertify.alert(alert_title, err.errormsg);
|
||||
} catch (e) {
|
||||
Alertify.alert(alert_title, e.statusText);
|
||||
}
|
||||
}
|
||||
|
||||
resize_panels() {
|
||||
let $src_ddl = $('#schema-diff-ddl-comp .source_ddl'),
|
||||
$tar_ddl = $('#schema-diff-ddl-comp .target_ddl'),
|
||||
$diff_ddl = $('#schema-diff-ddl-comp .diff_ddl'),
|
||||
footer_height = $('#schema-diff-ddl-comp').height() - 50;
|
||||
|
||||
$src_ddl.height(footer_height);
|
||||
$src_ddl.css({
|
||||
'height': footer_height + 'px',
|
||||
});
|
||||
$tar_ddl.height(footer_height);
|
||||
$tar_ddl.css({
|
||||
'height': footer_height + 'px',
|
||||
});
|
||||
$diff_ddl.height(footer_height);
|
||||
$diff_ddl.css({
|
||||
'height': footer_height + 'px',
|
||||
});
|
||||
|
||||
this.resize_grid();
|
||||
}
|
||||
|
||||
compare_schemas() {
|
||||
var self = this,
|
||||
url_params = self.model.toJSON();
|
||||
|
||||
if (url_params['source_sid'] == '' || _.isUndefined(url_params['source_sid']) ||
|
||||
url_params['source_did'] == '' || _.isUndefined(url_params['source_did']) ||
|
||||
url_params['source_scid'] == '' || _.isUndefined(url_params['source_scid']) ||
|
||||
url_params['target_sid'] == '' || _.isUndefined(url_params['target_sid']) ||
|
||||
url_params['target_did'] == '' || _.isUndefined(url_params['target_did']) ||
|
||||
url_params['target_scid'] == '' || _.isUndefined(url_params['target_scid'])
|
||||
) {
|
||||
Alertify.alert(gettext('Selection Error'), gettext('Please select source and target.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
this.selection = JSON.parse(JSON.stringify(url_params));
|
||||
|
||||
url_params['trans_id'] = self.trans_id;
|
||||
|
||||
_.each(url_params, function(key, val) {
|
||||
url_params[key] = parseInt(val, 10);
|
||||
});
|
||||
|
||||
var baseUrl = url_for('schema_diff.compare', url_params);
|
||||
|
||||
self.model.set({
|
||||
'source_ddl': undefined,
|
||||
'target_ddl': undefined,
|
||||
'diff_ddl': undefined,
|
||||
});
|
||||
|
||||
self.render_grid([]);
|
||||
self.footer.render();
|
||||
self.startDiffPoller();
|
||||
|
||||
return $.ajax({
|
||||
url: baseUrl,
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
})
|
||||
.done(function (res) {
|
||||
self.stopDiffPoller();
|
||||
self.render_grid(res.data);
|
||||
})
|
||||
.fail(function (xhr) {
|
||||
self.raise_error_on_fail(gettext('Schema compare error'), xhr);
|
||||
self.stopDiffPoller();
|
||||
});
|
||||
}
|
||||
|
||||
generate_script() {
|
||||
var self = this,
|
||||
baseServerUrl = url_for('schema_diff.get_server', {'sid': self.selection['target_sid'],
|
||||
'did': self.selection['target_did']}),
|
||||
sel_rows = self.grid ? self.grid.getSelectedRows() : [],
|
||||
sel_rows_data = [],
|
||||
url_params = self.selection,
|
||||
generated_script = undefined,
|
||||
open_query_tool;
|
||||
|
||||
_.each(url_params, function(key, val) {
|
||||
url_params[key] = parseInt(val, 10);
|
||||
});
|
||||
|
||||
$('#diff_fetching_data').removeClass('d-none');
|
||||
$('#diff_fetching_data').find('.schema-diff-busy-text').text('Generating script...');
|
||||
|
||||
|
||||
open_query_tool = function get_server_details() {
|
||||
$.ajax({
|
||||
url: baseServerUrl,
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
})
|
||||
.done(function (res) {
|
||||
let data = res.data;
|
||||
let server_data = {};
|
||||
if (data) {
|
||||
server_data['sgid'] = data.gid;
|
||||
server_data['sid'] = data.sid;
|
||||
server_data['stype'] = data.type;
|
||||
server_data['server'] = data.name;
|
||||
server_data['user'] = data.user;
|
||||
server_data['did'] = self.model.get('target_did');
|
||||
server_data['database'] = data.database;
|
||||
|
||||
if (_.isUndefined(generated_script))
|
||||
generated_script = 'BEGIN;' + '\n' + self.model.get('diff_ddl') + '\n' + 'END;';
|
||||
|
||||
let preferences = pgWindow.pgAdmin.Browser.get_preferences_for_module('schema_diff');
|
||||
if (preferences.schema_diff_new_browser_tab) {
|
||||
pgWindow.pgAdmin.ddl_diff = generated_script;
|
||||
generateScript(server_data, pgWindow.pgAdmin.DataGrid);
|
||||
} else {
|
||||
pgWindow.pgAdmin.ddl_diff = generated_script;
|
||||
generateScript(server_data, pgWindow.pgAdmin.DataGrid);
|
||||
}
|
||||
}
|
||||
|
||||
$('#diff_fetching_data').find('.schema-diff-busy-text').text('');
|
||||
$('#diff_fetching_data').addClass('d-none');
|
||||
|
||||
})
|
||||
.fail(function (xhr) {
|
||||
self.raise_error_on_fail(gettext('Generate script error'), xhr);
|
||||
$('#diff_fetching_data').find('.schema-diff-busy-text').text('');
|
||||
$('#diff_fetching_data').addClass('d-none');
|
||||
});
|
||||
};
|
||||
|
||||
if (sel_rows.length > 0) {
|
||||
for (var row = 0; row < sel_rows.length; row++) {
|
||||
let data = self.grid.getData().getItem(sel_rows[row]);
|
||||
|
||||
if (data.type) {
|
||||
let tmp_data = {
|
||||
'node_type': data.type,
|
||||
'source_oid': parseInt(data.oid, 10),
|
||||
'target_oid': parseInt(data.oid, 10),
|
||||
'comp_status': data.status,
|
||||
};
|
||||
|
||||
if(data.status && (data.status.toLowerCase() == 'different' || data.status.toLowerCase() == 'identical')) {
|
||||
tmp_data['target_oid'] = data.target_oid;
|
||||
}
|
||||
sel_rows_data.push(tmp_data);
|
||||
}
|
||||
}
|
||||
|
||||
url_params['sel_rows'] = sel_rows_data;
|
||||
|
||||
let baseUrl = url_for('schema_diff.generate_script', {'trans_id': self.trans_id});
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl,
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(url_params),
|
||||
})
|
||||
.done(function (res) {
|
||||
if (res) {
|
||||
generated_script = 'BEGIN;' + '\n' + res.diff_ddl + '\n' + 'END;';
|
||||
}
|
||||
open_query_tool();
|
||||
})
|
||||
.fail(function (xhr) {
|
||||
self.raise_error_on_fail(gettext('Generate script error'), xhr);
|
||||
$('#diff_fetching_data').addClass('d-none');
|
||||
});
|
||||
} else if (!_.isUndefined(self.model.get('diff_ddl'))) {
|
||||
open_query_tool();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
render_grid(data) {
|
||||
|
||||
var self = this;
|
||||
var grid;
|
||||
|
||||
if (self.grid) {
|
||||
// Only render the data
|
||||
self.render_grid_data(data);
|
||||
return;
|
||||
}
|
||||
// Checkbox Column
|
||||
var checkboxSelector = new Slick.CheckboxSelectColumn({
|
||||
cssClass: 'slick-cell-checkboxsel',
|
||||
minWidth: 30,
|
||||
});
|
||||
|
||||
// Format Schema object title with appropriate icon
|
||||
var formatColumnTitle = function (row, cell, value, columnDef, dataContext) {
|
||||
let icon = 'icon-' + dataContext.type;
|
||||
return '<i class="ml-5 wcTabIcon '+ icon +'"></i><span>' + value + '</span>';
|
||||
};
|
||||
|
||||
// Grid Columns
|
||||
var grid_width = (self.grid_width - 47) / 2 ;
|
||||
var columns = [
|
||||
checkboxSelector.getColumnDefinition(),
|
||||
{id: 'title', name: 'Schema Objects', field: 'title', minWidth: grid_width, formatter: formatColumnTitle},
|
||||
{id: 'status', name: 'Comparison Result', field: 'status', minWidth: grid_width},
|
||||
{id: 'label', name: 'Schema Objects', field: 'label', width: 0, minWidth: 0, maxWidth: 0,
|
||||
cssClass: 'really-hidden', headerCssClass: 'really-hidden'},
|
||||
{id: 'type', name: 'Schema Objects', field: 'type', width: 0, minWidth: 0, maxWidth: 0,
|
||||
cssClass: 'really-hidden', headerCssClass: 'really-hidden'},
|
||||
{id: 'id', name: 'id', field: 'id', width: 0, minWidth: 0, maxWidth: 0,
|
||||
cssClass: 'really-hidden', headerCssClass: 'really-hidden' },
|
||||
|
||||
];
|
||||
|
||||
// Grid Options
|
||||
var options = {
|
||||
enableCellNavigation: true,
|
||||
enableColumnReorder: false,
|
||||
enableRowSelection: true,
|
||||
};
|
||||
|
||||
// Grouping by Schema Object
|
||||
self.groupBySchemaObject = function() {
|
||||
self.dataView.setGrouping({
|
||||
getter: 'type',
|
||||
formatter: function (g) {
|
||||
let icon = 'icon-coll-' + g.value;
|
||||
return '<i class="wcTabIcon '+ icon +'"></i><span>' + g.rows[0].label + '</span>';
|
||||
},
|
||||
aggregateCollapsed: true,
|
||||
lazyTotalsCalculation: true,
|
||||
});
|
||||
};
|
||||
|
||||
var groupItemMetadataProvider = new Slick.Data.GroupItemMetadataProvider({ checkboxSelect: true,
|
||||
checkboxSelectPlugin: checkboxSelector });
|
||||
|
||||
// Dataview for grid
|
||||
self.dataView = new Slick.Data.DataView({
|
||||
groupItemMetadataProvider: groupItemMetadataProvider,
|
||||
inlineFilters: false,
|
||||
});
|
||||
|
||||
// Wire up model events to drive the grid
|
||||
self.dataView.onRowCountChanged.subscribe(function () {
|
||||
grid.updateRowCount();
|
||||
grid.render();
|
||||
});
|
||||
self.dataView.onRowsChanged.subscribe(function (e, args) {
|
||||
grid.invalidateRows(args.rows);
|
||||
grid.render();
|
||||
});
|
||||
|
||||
// Change Row css on the basis of item status
|
||||
self.dataView.getItemMetadata = function(row) {
|
||||
var item = self.dataView.getItem(row);
|
||||
if (item.__group) {
|
||||
return groupItemMetadataProvider.getGroupRowMetadata(item);
|
||||
}
|
||||
|
||||
if(item.status === 'Different') {
|
||||
return { cssClasses: 'different' };
|
||||
} else if (item.status === 'Source Only') {
|
||||
return { cssClasses: 'source' };
|
||||
} else if (item.status === 'Target Only') {
|
||||
return { cssClasses: 'target' };
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
// Grid filter
|
||||
self.filter = function (item) {
|
||||
let self = this;
|
||||
if (self.sel_filters.indexOf(item.status) !== -1) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
let $data_grid = $('#schema-diff-grid');
|
||||
grid = this.grid = new Slick.Grid($data_grid, self.dataView, columns, options);
|
||||
grid.registerPlugin(groupItemMetadataProvider);
|
||||
grid.setSelectionModel(new Slick.RowSelectionModel({selectActiveRow: false}));
|
||||
grid.registerPlugin(checkboxSelector);
|
||||
|
||||
grid.onClick.subscribe(function(e, args) {
|
||||
if (args.row) {
|
||||
data = args.grid.getData().getItem(args.row);
|
||||
if (data.status) this.ddlCompare(data);
|
||||
}
|
||||
}.bind(self));
|
||||
|
||||
grid.onSelectedRowsChanged.subscribe(self.handle_generate_button.bind(self));
|
||||
|
||||
self.model.on('change:diff_ddl', self.handle_generate_button.bind(self));
|
||||
|
||||
$('#schema-diff-grid').on('keyup', function() {
|
||||
if ((event.keyCode == 38 || event.keyCode ==40) && this.grid.getActiveCell().row) {
|
||||
data = this.grid.getData().getItem(this.grid.getActiveCell().row);
|
||||
this.ddlCompare(data);
|
||||
}
|
||||
}.bind(self));
|
||||
|
||||
self.render_grid_data(data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
render_grid_data(data) {
|
||||
var self = this;
|
||||
self.dataView.beginUpdate();
|
||||
self.dataView.setItems(data);
|
||||
self.dataView.setFilter(self.filter.bind(self));
|
||||
self.groupBySchemaObject();
|
||||
self.dataView.endUpdate();
|
||||
|
||||
self.resize_grid();
|
||||
}
|
||||
|
||||
handle_generate_button(){
|
||||
if (this.grid.getSelectedRows().length > 0 || (this.model.get('diff_ddl') != '' && !_.isUndefined(this.model.get('diff_ddl')))) {
|
||||
this.header.$el.find('button#generate-script').removeAttr('disabled');
|
||||
} else {
|
||||
this.header.$el.find('button#generate-script').attr('disabled', true);
|
||||
}
|
||||
}
|
||||
|
||||
resize_grid() {
|
||||
let $data_grid = $('#schema-diff-grid'),
|
||||
grid_height = (this.panel_obj.height() > 0) ? this.panel_obj.height() - 100 : this.grid_height - 100;
|
||||
|
||||
$data_grid.height(grid_height);
|
||||
$data_grid.css({
|
||||
'height': grid_height + 'px',
|
||||
});
|
||||
if (this.grid) this.grid.resizeCanvas();
|
||||
}
|
||||
|
||||
getCompareStatus() {
|
||||
var self = this,
|
||||
url_params = {'trans_id': self.trans_id},
|
||||
baseUrl = url_for('schema_diff.poll', url_params);
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl,
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
})
|
||||
.done(function (res) {
|
||||
let msg = res.data.compare_msg + res.data.diff_percentage + '% completed';
|
||||
$('#diff_fetching_data').find('.schema-diff-busy-text').text(msg);
|
||||
})
|
||||
.fail(function (xhr) {
|
||||
self.raise_error_on_fail(gettext('Poll error'), xhr);
|
||||
self.stopDiffPoller('fail');
|
||||
});
|
||||
}
|
||||
|
||||
startDiffPoller() {
|
||||
$('#ddl_comp_fetching_data').addClass('d-none');
|
||||
$('#diff_fetching_data').removeClass('d-none');
|
||||
/* Execute once for the first time as setInterval will not do */
|
||||
this.getCompareStatus();
|
||||
this.diff_poller_int_id = setInterval(this.getCompareStatus.bind(this), 1000);
|
||||
}
|
||||
|
||||
stopDiffPoller(status) {
|
||||
clearInterval(this.diff_poller_int_id);
|
||||
// The last polling for comparison
|
||||
if (status !== 'fail') this.getCompareStatus();
|
||||
|
||||
$('#diff_fetching_data').find('.schema-diff-busy-text').text('');
|
||||
$('#diff_fetching_data').addClass('d-none');
|
||||
|
||||
}
|
||||
|
||||
ddlCompare(data) {
|
||||
var self = this,
|
||||
node_type = data.type,
|
||||
source_oid = data.oid,
|
||||
target_oid = data.oid;
|
||||
|
||||
self.model.set({
|
||||
'source_ddl': undefined,
|
||||
'target_ddl': undefined,
|
||||
'diff_ddl': undefined,
|
||||
});
|
||||
|
||||
var url_params = self.selection;
|
||||
|
||||
if(data.status && (data.status.toLowerCase() == 'different' || data.status.toLowerCase() == 'identical')) {
|
||||
target_oid = data.target_oid;
|
||||
}
|
||||
|
||||
url_params['trans_id'] = self.trans_id;
|
||||
url_params['source_oid'] = source_oid;
|
||||
url_params['target_oid'] = target_oid;
|
||||
url_params['comp_status'] = data.status;
|
||||
url_params['node_type'] = node_type;
|
||||
|
||||
_.each(url_params, function(key, val) {
|
||||
url_params[key] = parseInt(val, 10);
|
||||
});
|
||||
|
||||
$('#ddl_comp_fetching_data').removeClass('d-none');
|
||||
|
||||
var baseUrl = url_for('schema_diff.ddl_compare', url_params);
|
||||
self.model.url = baseUrl;
|
||||
|
||||
self.model.fetch({
|
||||
success: function() {
|
||||
self.footer.render();
|
||||
$('#ddl_comp_fetching_data').addClass('d-none');
|
||||
},
|
||||
error: function() {
|
||||
self.footer.render();
|
||||
$('#ddl_comp_fetching_data').addClass('d-none');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
let self = this;
|
||||
let panel = self.docker.findPanels('schema_diff_header_panel')[0];
|
||||
|
||||
var header = panel.$container.find('#schema-diff-header');
|
||||
|
||||
self.header = new SchemaDiffHeaderView({
|
||||
el: header,
|
||||
model: this.model,
|
||||
fields: [{
|
||||
name: 'source_sid', label: false,
|
||||
control: SchemaDiffSelect2Control,
|
||||
url: url_for('schema_diff.servers'),
|
||||
select2: {
|
||||
allowClear: true,
|
||||
placeholder: gettext('Select server...'),
|
||||
},
|
||||
connect: function() {
|
||||
self.connect_server(arguments[0], arguments[1]);
|
||||
},
|
||||
group: 'source',
|
||||
disabled: function() {
|
||||
return false;
|
||||
},
|
||||
}, {
|
||||
name: 'source_did',
|
||||
group: 'source',
|
||||
deps: ['source_sid'],
|
||||
control: SchemaDiffSelect2Control,
|
||||
url: function() {
|
||||
if (this.get('source_sid'))
|
||||
return url_for('schema_diff.databases', {'sid': this.get('source_sid')});
|
||||
return false;
|
||||
},
|
||||
select2: {
|
||||
allowClear: true,
|
||||
placeholder: gettext('Select database...'),
|
||||
},
|
||||
disabled: function(m) {
|
||||
if (!_.isUndefined(m.get('source_sid')) && !_.isNull(m.get('source_sid')))
|
||||
return false;
|
||||
return true;
|
||||
},
|
||||
connect: function() {
|
||||
self.connect_database(this.model.get('source_sid'), arguments[0], arguments[1]);
|
||||
},
|
||||
}, {
|
||||
name: 'source_scid',
|
||||
control: SchemaDiffSelect2Control,
|
||||
group: 'source',
|
||||
deps: ['source_sid', 'source_did'],
|
||||
url: function() {
|
||||
if (this.get('source_sid') && this.get('source_did'))
|
||||
return url_for('schema_diff.schemas', {'sid': this.get('source_sid'), 'did': this.get('source_did')});
|
||||
return false;
|
||||
},
|
||||
select2: {
|
||||
allowClear: true,
|
||||
placeholder: gettext('Select schema...'),
|
||||
},
|
||||
disabled: function(m) {
|
||||
if (!_.isUndefined(m.get('source_did')) && !_.isNull(m.get('source_did')))
|
||||
return false;
|
||||
return true;
|
||||
},
|
||||
}, {
|
||||
name: 'target_sid', label: false,
|
||||
control: SchemaDiffSelect2Control,
|
||||
group: 'target',
|
||||
url: url_for('schema_diff.servers'),
|
||||
select2: {
|
||||
allowClear: true,
|
||||
placeholder: gettext('Select server...'),
|
||||
},
|
||||
disabled: function() {
|
||||
return false;
|
||||
},
|
||||
connect: function() {
|
||||
self.connect_server(arguments[0], arguments[1]);
|
||||
},
|
||||
}, {
|
||||
name: 'target_did',
|
||||
control: SchemaDiffSelect2Control,
|
||||
group: 'target',
|
||||
deps: ['target_sid'],
|
||||
url: function() {
|
||||
if (this.get('target_sid'))
|
||||
return url_for('schema_diff.databases', {'sid': this.get('target_sid')});
|
||||
return false;
|
||||
},
|
||||
select2: {
|
||||
allowClear: true,
|
||||
placeholder: gettext('Select database...'),
|
||||
},
|
||||
disabled: function(m) {
|
||||
if (!_.isUndefined(m.get('target_sid')) && !_.isNull(m.get('target_sid')))
|
||||
return false;
|
||||
return true;
|
||||
},
|
||||
connect: function() {
|
||||
self.connect_database(this.model.get('target_sid'), arguments[0], arguments[1]);
|
||||
},
|
||||
}, {
|
||||
name: 'target_scid',
|
||||
control: SchemaDiffSelect2Control,
|
||||
group: 'target',
|
||||
deps: ['target_sid', 'target_did'],
|
||||
url: function() {
|
||||
if (this.get('target_sid') && this.get('target_did'))
|
||||
return url_for('schema_diff.schemas', {'sid': this.get('target_sid'), 'did': this.get('target_did')});
|
||||
return false;
|
||||
},
|
||||
select2: {
|
||||
allowClear: true,
|
||||
placeholder: gettext('Select schema...'),
|
||||
},
|
||||
disabled: function(m) {
|
||||
if (!_.isUndefined(m.get('target_did')) && !_.isNull(m.get('target_did')))
|
||||
return false;
|
||||
return true;
|
||||
},
|
||||
}],
|
||||
});
|
||||
|
||||
self.footer = new SchemaDiffFooterView({
|
||||
model: this.model,
|
||||
fields: [{
|
||||
name: 'source_ddl', label: false,
|
||||
control: SchemaDiffSqlControl,
|
||||
group: 'ddl-source',
|
||||
}, {
|
||||
name: 'target_ddl', label: false,
|
||||
control: SchemaDiffSqlControl,
|
||||
group: 'ddl-target',
|
||||
}, {
|
||||
name: 'diff_ddl', label: false,
|
||||
control: SchemaDiffSqlControl,
|
||||
group: 'ddl-diff', copyRequired: true,
|
||||
}],
|
||||
});
|
||||
|
||||
self.header.render();
|
||||
|
||||
self.header.$el.find('button.btn-primary').on('click', self.compare_schemas.bind(self));
|
||||
self.header.$el.find('button#generate-script').on('click', self.generate_script.bind(self));
|
||||
self.header.$el.find('ul.filter a.dropdown-item').on('click', self.refresh_filters.bind(self));
|
||||
|
||||
let footer_panel = self.docker.findPanels('schema_diff_footer_panel')[0],
|
||||
header_panel = self.docker.findPanels('schema_diff_header_panel')[0];
|
||||
|
||||
footer_panel.$container.find('#schema-diff-ddl-comp').append(self.footer.render().$el);
|
||||
header_panel.$container.find('#schema-diff-grid').append(`<div class='obj_properties container-fluid'>
|
||||
<div class='alert alert-info pg-panel-message'>` + gettext('Select the server, database and schema for the source and target and click <b>Compare</b> to compare them.') + '</div></div>');
|
||||
|
||||
self.grid_width = $('#schema-diff-grid').width();
|
||||
self.grid_height = this.panel_obj.height();
|
||||
}
|
||||
|
||||
refresh_filters(event) {
|
||||
let self = this;
|
||||
_.each(self.filters, function(filter) {
|
||||
let index = self.sel_filters.indexOf(filter);
|
||||
let filter_class = '.' + filter.replace(' ', '-').toLowerCase();
|
||||
if ($(event.currentTarget).find(filter_class).length == 1) {
|
||||
if ($(filter_class).hasClass('visibility-hidden') === true) {
|
||||
$(filter_class).removeClass('visibility-hidden');
|
||||
if (index === -1) self.sel_filters.push(filter);
|
||||
} else {
|
||||
$(filter_class).addClass('visibility-hidden');
|
||||
if(index !== -1 ) delete self.sel_filters[index];
|
||||
}
|
||||
}
|
||||
});
|
||||
// Refresh the grid
|
||||
self.dataView.refresh();
|
||||
}
|
||||
|
||||
connect_database(server_id, db_id, callback) {
|
||||
var url = url_for('schema_diff.connect_database', {'sid': server_id, 'did': db_id});
|
||||
$.post(url)
|
||||
.done(function(res) {
|
||||
if (res.success && res.data) {
|
||||
callback(res.data);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, error) {
|
||||
Alertify.pgNotifier(error, xhr, gettext('Failed to connect the database.'));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
connect_server(server_id, callback) {
|
||||
var onFailure = function(
|
||||
xhr, status, error, server_id, callback
|
||||
) {
|
||||
Alertify.pgNotifier('error', xhr, error, function(msg) {
|
||||
setTimeout(function() {
|
||||
Alertify.dlgServerPass(
|
||||
gettext('Connect to Server'),
|
||||
msg,
|
||||
server_id,
|
||||
callback
|
||||
).resizeTo();
|
||||
}, 100);
|
||||
});
|
||||
},
|
||||
onSuccess = function(res, callback) {
|
||||
if (res && res.data) {
|
||||
// We're not reconnecting
|
||||
callback(res.data);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Ask Password and send it back to the connect server
|
||||
if (!Alertify.dlgServerPass) {
|
||||
Alertify.dialog('dlgServerPass', function factory() {
|
||||
return {
|
||||
main: function(
|
||||
title, message, server_id, success_callback, _onSuccess, _onFailure, _onCancel
|
||||
) {
|
||||
this.set('title', title);
|
||||
this.message = message;
|
||||
this.server_id = server_id;
|
||||
this.success_callback = success_callback;
|
||||
this.onSuccess = _onSuccess || onSuccess;
|
||||
this.onFailure = _onFailure || onFailure;
|
||||
this.onCancel = _onCancel || onCancel;
|
||||
},
|
||||
setup:function() {
|
||||
return {
|
||||
buttons:[{
|
||||
text: gettext('Cancel'), className: 'btn btn-secondary fa fa-times pg-alertify-button',
|
||||
key: 27,
|
||||
},{
|
||||
text: gettext('OK'), key: 13, className: 'btn btn-primary fa fa-check pg-alertify-button',
|
||||
}],
|
||||
focus: {element: '#password', select: true},
|
||||
options: {
|
||||
modal: 0, resizable: false, maximizable: false, pinnable: false,
|
||||
},
|
||||
};
|
||||
},
|
||||
build:function() {},
|
||||
prepare:function() {
|
||||
this.setContent(this.message);
|
||||
},
|
||||
callback: function(closeEvent) {
|
||||
var _onFailure = this.onFailure,
|
||||
_onSuccess = this.onSuccess,
|
||||
_onCancel = this.onCancel,
|
||||
_success_callback = this.success_callback;
|
||||
|
||||
if (closeEvent.button.text == gettext('OK')) {
|
||||
|
||||
var _url = url_for('schema_diff.connect_server', {'sid': this.server_id});
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
timeout: 30000,
|
||||
url: _url,
|
||||
data: $('#frmPassword').serialize(),
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
return _onSuccess(res, _success_callback);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
return _onFailure(
|
||||
xhr, status, error, this.server_id, _success_callback
|
||||
);
|
||||
});
|
||||
} else {
|
||||
_onCancel && typeof(_onCancel) == 'function' &&
|
||||
_onCancel();
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
var onCancel = function() {
|
||||
return false;
|
||||
};
|
||||
|
||||
var url = url_for('schema_diff.connect_server', {'sid': server_id});
|
||||
$.post(url)
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
return onSuccess(res, callback);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
return onFailure(
|
||||
xhr, status, error, server_id, callback
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
85
web/pgadmin/tools/schema_diff/static/scss/_schema_diff.scss
Normal file
85
web/pgadmin/tools/schema_diff/static/scss/_schema_diff.scss
Normal file
@@ -0,0 +1,85 @@
|
||||
#schema-diff-container {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
padding-top: 10px;
|
||||
background-color: $color-gray-light;
|
||||
}
|
||||
|
||||
#schema-diff-grid {
|
||||
background: $color-bg;
|
||||
outline: 0;
|
||||
font-size: 9pt;
|
||||
margin-top: 28px;
|
||||
background: none;
|
||||
background-color: $color-gray-light;
|
||||
}
|
||||
|
||||
#schema-diff-grid .slick-header .slick-header-columns {
|
||||
background: $color-bg;
|
||||
height: 40px;
|
||||
border-bottom: $panel-border;
|
||||
}
|
||||
|
||||
#schema-diff-grid .slick-header .slick-header-column.ui-state-default {
|
||||
padding: 4px 0 3px 6px;
|
||||
border-bottom: $panel-border;
|
||||
border-right: $panel-border;
|
||||
}
|
||||
|
||||
.slick-row:hover .slick-cell{
|
||||
border-top: $table-hover-border;
|
||||
border-bottom: $table-hover-border;
|
||||
background-color: $table-hover-bg-color;
|
||||
}
|
||||
|
||||
#schema-diff-grid .slick-header .slick-header-column.selected {
|
||||
background-color: $color-primary;
|
||||
color: $color-primary-fg;
|
||||
}
|
||||
.slick-row .slick-cell {
|
||||
border-bottom: $panel-border;
|
||||
border-right: $panel-border;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
#schema-diff-grid .slick-row .slick-cell.l0.r0.selected {
|
||||
background-color: $color-primary;
|
||||
color: $color-primary-fg;
|
||||
}
|
||||
|
||||
#schema-diff-grid .slick-row > .slick-cell:not(.l0):not(.r0).selected {
|
||||
background-color: $table-hover-bg-color;
|
||||
border-top: $table-hover-border;
|
||||
border-bottom: $table-hover-border;
|
||||
}
|
||||
|
||||
#schema-diff-grid div.slick-header.ui-state-default {
|
||||
background: $color-bg;
|
||||
border-bottom: none;
|
||||
border-right: none;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
#schema-diff-grid .different {
|
||||
background-color: $schemadiff-diff-row-color !important;
|
||||
}
|
||||
#schema-diff-grid .source {
|
||||
background-color: $schemadiff-source-row-color !important;
|
||||
}
|
||||
#schema-diff-grid .target {
|
||||
background-color: $schemadiff-target-row-color !important;
|
||||
}
|
||||
|
||||
#schema-diff-grid .slick-row.active {
|
||||
background-color: $table-bg-selected !important;
|
||||
}
|
||||
|
||||
#schema-diff-ddl-comp {
|
||||
height: 100%;
|
||||
bottom: 10px;
|
||||
background-color: $color-bg !important;
|
||||
overflow-y: hidden;
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
{% extends "base.html" %}
|
||||
{% block init_script %}
|
||||
try {
|
||||
require(
|
||||
['sources/generated/schema_diff', 'sources/generated/slickgrid', 'sources/generated/codemirror', 'sources/generated/browser_nodes'],
|
||||
function(pgSchemaDiffHook) {
|
||||
var pgSchemaDiffHook = pgSchemaDiffHook || pgAdmin.Tools.SchemaDiffHook;
|
||||
pgSchemaDiffHook.load({{trans_id}});
|
||||
},
|
||||
function() {
|
||||
console.log(arguments);
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
{% endblock %}
|
||||
{% block css_link %}
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('browser.browser_css')}}"/>
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
<div id="schema-diff-container">
|
||||
<div id="diff_fetching_data" class="pg-sp-container schema-diff-busy-fetching d-none">
|
||||
<div class="pg-sp-content">
|
||||
<div class="row">
|
||||
<div class="col-12 pg-sp-icon"></div>
|
||||
</div>
|
||||
<div class="row"><div class="col-12 pg-sp-text schema-diff-busy-text"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
0
web/pgadmin/tools/schema_diff/tests/__init__.py
Normal file
0
web/pgadmin/tools/schema_diff/tests/__init__.py
Normal file
440
web/pgadmin/tools/schema_diff/tests/pg/10_plus/source.sql
Normal file
440
web/pgadmin/tools/schema_diff/tests/pg/10_plus/source.sql
Normal file
@@ -0,0 +1,440 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.7
|
||||
-- Dumped by pg_dump version 12beta2
|
||||
|
||||
-- Started on 2019-11-01 12:54:15 IST
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- TOC entry 17 (class 2615 OID 139770)
|
||||
-- Name: source; Type: SCHEMA; Schema: -; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SCHEMA source;
|
||||
|
||||
|
||||
ALTER SCHEMA source OWNER TO postgres;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA source;
|
||||
|
||||
--
|
||||
-- TOC entry 12272 (class 1259 OID 149205)
|
||||
-- Name: table_for_partition; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_partition (
|
||||
col1 bigint NOT NULL
|
||||
)
|
||||
PARTITION BY RANGE (col1);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_partition OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12273 (class 1259 OID 149208)
|
||||
-- Name: part1; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.part1 (
|
||||
col1 bigint NOT NULL
|
||||
);
|
||||
ALTER TABLE ONLY source.table_for_partition ATTACH PARTITION source.part1 FOR VALUES FROM ('1') TO ('23');
|
||||
|
||||
|
||||
ALTER TABLE source.part1 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12274 (class 1259 OID 149213)
|
||||
-- Name: table_for_partition_1; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_partition_1 (
|
||||
col1 bigint
|
||||
)
|
||||
PARTITION BY RANGE (col1);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_partition_1 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12275 (class 1259 OID 149216)
|
||||
-- Name: part3; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.part3 (
|
||||
col1 bigint
|
||||
);
|
||||
ALTER TABLE ONLY source.table_for_partition_1 ATTACH PARTITION source.part3 FOR VALUES FROM ('1') TO ('10');
|
||||
|
||||
|
||||
ALTER TABLE source.part3 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12276 (class 1259 OID 149219)
|
||||
-- Name: part4; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.part4 (
|
||||
col1 bigint
|
||||
);
|
||||
ALTER TABLE ONLY source.table_for_partition_1 ATTACH PARTITION source.part4 FOR VALUES FROM ('11') TO ('20');
|
||||
|
||||
|
||||
ALTER TABLE source.part4 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12258 (class 1259 OID 148963)
|
||||
-- Name: table_for_column; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_column (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text,
|
||||
col3 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_column OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12256 (class 1259 OID 148895)
|
||||
-- Name: table_for_constraints; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_constraints (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_constraints OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61066 (class 0 OID 0)
|
||||
-- Dependencies: 12256
|
||||
-- Name: TABLE table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON TABLE source.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12262 (class 1259 OID 149004)
|
||||
-- Name: table_for_identical; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_identical (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_identical OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12260 (class 1259 OID 148977)
|
||||
-- Name: table_for_index; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_index (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_index OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12269 (class 1259 OID 149128)
|
||||
-- Name: table_for_primary_key; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_primary_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_primary_key OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12264 (class 1259 OID 149024)
|
||||
-- Name: table_for_rule; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_rule (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_rule OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12266 (class 1259 OID 149048)
|
||||
-- Name: table_for_trigger; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_trigger (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_trigger OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 56893 (class 2606 OID 148904)
|
||||
-- Name: table_for_constraints Exclusion; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT "Exclusion" EXCLUDE USING gist (col2 WITH <>) WITH (fillfactor='12') WHERE ((col1 > 1)) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61067 (class 0 OID 0)
|
||||
-- Dependencies: 56893
|
||||
-- Name: CONSTRAINT "Exclusion" ON table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "Exclusion" ON source.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56891 (class 2606 OID 148911)
|
||||
-- Name: table_for_constraints check_con; Type: CHECK CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE source.table_for_constraints
|
||||
ADD CONSTRAINT check_con CHECK ((col1 > 10)) NOT VALID;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61068 (class 0 OID 0)
|
||||
-- Dependencies: 56891
|
||||
-- Name: CONSTRAINT check_con ON table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT check_con ON source.table_for_constraints IS 'coment';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56899 (class 2606 OID 148970)
|
||||
-- Name: table_for_column table_for_column_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_column
|
||||
ADD CONSTRAINT table_for_column_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56895 (class 2606 OID 148902)
|
||||
-- Name: table_for_constraints table_for_constraints_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT table_for_constraints_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56904 (class 2606 OID 148984)
|
||||
-- Name: table_for_index table_for_index_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_index
|
||||
ADD CONSTRAINT table_for_index_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56913 (class 2606 OID 149135)
|
||||
-- Name: table_for_primary_key table_for_primary_key_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_primary_key
|
||||
ADD CONSTRAINT table_for_primary_key_pkey PRIMARY KEY (col1, col2);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56909 (class 2606 OID 149031)
|
||||
-- Name: table_for_rule table_for_rule_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_rule
|
||||
ADD CONSTRAINT table_for_rule_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56907 (class 2606 OID 149011)
|
||||
-- Name: table_for_identical table_for_table_for_identical_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_identical
|
||||
ADD CONSTRAINT table_for_table_for_identical_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56911 (class 2606 OID 149055)
|
||||
-- Name: table_for_trigger table_for_trigger_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_trigger
|
||||
ADD CONSTRAINT table_for_trigger_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56897 (class 2606 OID 148913)
|
||||
-- Name: table_for_constraints unique; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT "unique" UNIQUE (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61069 (class 0 OID 0)
|
||||
-- Dependencies: 56897
|
||||
-- Name: CONSTRAINT "unique" ON table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "unique" ON source.table_for_constraints IS 'cmnt';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56900 (class 1259 OID 149023)
|
||||
-- Name: index1; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index1 ON source.table_for_index USING btree (col2 varchar_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56905 (class 1259 OID 149012)
|
||||
-- Name: index_identical; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_identical ON source.table_for_identical USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56901 (class 1259 OID 149211)
|
||||
-- Name: index_same; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_same ON source.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56902 (class 1259 OID 149022)
|
||||
-- Name: index_source; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_source ON source.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61044 (class 2618 OID 149032)
|
||||
-- Name: table_for_rule rule1; Type: RULE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule1 AS
|
||||
ON UPDATE TO source.table_for_rule DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61070 (class 0 OID 0)
|
||||
-- Dependencies: 61044
|
||||
-- Name: RULE rule1 ON table_for_rule; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON RULE rule1 ON source.table_for_rule IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61045 (class 2618 OID 149033)
|
||||
-- Name: table_for_rule rule2; Type: RULE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule2 AS
|
||||
ON INSERT TO source.table_for_rule DO NOTHING;
|
||||
|
||||
--
|
||||
-- TOC entry 12283 (class 1259 OID 347818)
|
||||
-- Name: test view; Type: VIEW; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW source."test view" AS
|
||||
SELECT pg_class.relname,
|
||||
pg_class.relnamespace,
|
||||
pg_class.reltype,
|
||||
pg_class.reloftype,
|
||||
pg_class.relowner,
|
||||
pg_class.relam,
|
||||
pg_class.relfilenode,
|
||||
pg_class.reltablespace,
|
||||
pg_class.relpages,
|
||||
pg_class.reltuples,
|
||||
pg_class.relallvisible,
|
||||
pg_class.reltoastrelid,
|
||||
pg_class.relhasindex,
|
||||
pg_class.relisshared,
|
||||
pg_class.relpersistence,
|
||||
pg_class.relkind,
|
||||
pg_class.relnatts,
|
||||
pg_class.relchecks,
|
||||
pg_class.relhasoids,
|
||||
pg_class.relhaspkey,
|
||||
pg_class.relhasrules,
|
||||
pg_class.relhastriggers,
|
||||
pg_class.relhassubclass,
|
||||
pg_class.relrowsecurity,
|
||||
pg_class.relforcerowsecurity,
|
||||
pg_class.relispopulated,
|
||||
pg_class.relreplident,
|
||||
pg_class.relispartition,
|
||||
pg_class.relfrozenxid,
|
||||
pg_class.relminmxid,
|
||||
pg_class.relacl,
|
||||
pg_class.reloptions,
|
||||
pg_class.relpartbound
|
||||
FROM pg_class
|
||||
LIMIT 10;
|
||||
|
||||
|
||||
ALTER TABLE source."test view" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12286 (class 1259 OID 347832)
|
||||
-- Name: test view f; Type: VIEW; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW source."test view f" WITH (security_barrier='false') AS
|
||||
SELECT 2;
|
||||
|
||||
|
||||
ALTER TABLE source."test view f" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61111 (class 0 OID 0)
|
||||
-- Dependencies: 12286
|
||||
-- Name: VIEW "test view f"; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON VIEW source."test view f" IS 'cmn';
|
429
web/pgadmin/tools/schema_diff/tests/pg/10_plus/target.sql
Normal file
429
web/pgadmin/tools/schema_diff/tests/pg/10_plus/target.sql
Normal file
@@ -0,0 +1,429 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.7
|
||||
-- Dumped by pg_dump version 12beta2
|
||||
|
||||
-- Started on 2019-11-01 12:55:22 IST
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- TOC entry 18 (class 2615 OID 139771)
|
||||
-- Name: target; Type: SCHEMA; Schema: -; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SCHEMA target;
|
||||
|
||||
ALTER SCHEMA target OWNER TO postgres;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA target;
|
||||
|
||||
--
|
||||
-- TOC entry 12250 (class 1259 OID 139938)
|
||||
-- Name: MView; Type: MATERIALIZED VIEW; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE MATERIALIZED VIEW target."MView" AS
|
||||
SELECT 'tekst'::text AS text
|
||||
WITH NO DATA;
|
||||
|
||||
|
||||
ALTER TABLE target."MView" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12277 (class 1259 OID 149234)
|
||||
-- Name: table_for_partition_1; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_partition_1 (
|
||||
col1 bigint
|
||||
)
|
||||
PARTITION BY RANGE (col1);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_partition_1 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12278 (class 1259 OID 149237)
|
||||
-- Name: part3; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.part3 (
|
||||
col1 bigint
|
||||
);
|
||||
ALTER TABLE ONLY target.table_for_partition_1 ATTACH PARTITION target.part3 FOR VALUES FROM ('13') TO ('56');
|
||||
|
||||
|
||||
ALTER TABLE target.part3 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12259 (class 1259 OID 148971)
|
||||
-- Name: table_for_column; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_column (
|
||||
col1 bigint,
|
||||
col2 bigint,
|
||||
col4 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_column OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12268 (class 1259 OID 149089)
|
||||
-- Name: table_for_constraints; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_constraints (
|
||||
col1 integer NOT NULL,
|
||||
col2 text,
|
||||
CONSTRAINT check_con CHECK ((col1 > 30))
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_constraints OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61066 (class 0 OID 0)
|
||||
-- Dependencies: 12268
|
||||
-- Name: TABLE table_for_constraints; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON TABLE target.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61067 (class 0 OID 0)
|
||||
-- Dependencies: 12268
|
||||
-- Name: CONSTRAINT check_con ON table_for_constraints; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT check_con ON target.table_for_constraints IS 'coment';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12257 (class 1259 OID 148960)
|
||||
-- Name: table_for_del; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_del (
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_del OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12271 (class 1259 OID 149172)
|
||||
-- Name: table_for_foreign_key; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_foreign_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 "char",
|
||||
col3 bigint
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_foreign_key OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12263 (class 1259 OID 149013)
|
||||
-- Name: table_for_identical; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_identical (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_identical OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12261 (class 1259 OID 148986)
|
||||
-- Name: table_for_index; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_index (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_index OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12270 (class 1259 OID 149144)
|
||||
-- Name: table_for_primary_key; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_primary_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_primary_key OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12265 (class 1259 OID 149034)
|
||||
-- Name: table_for_rule; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_rule (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_rule OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12267 (class 1259 OID 149066)
|
||||
-- Name: table_for_trigger; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_trigger (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_trigger OWNER TO postgres;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56906 (class 2606 OID 149097)
|
||||
-- Name: table_for_constraints Exclusion; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_constraints
|
||||
ADD CONSTRAINT "Exclusion" EXCLUDE USING gist (col2 WITH <>) WITH (fillfactor='15') WHERE ((col1 > 1)) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61068 (class 0 OID 0)
|
||||
-- Dependencies: 56906
|
||||
-- Name: CONSTRAINT "Exclusion" ON table_for_constraints; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "Exclusion" ON target.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56910 (class 2606 OID 149176)
|
||||
-- Name: table_for_foreign_key table_for_foreign_key_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_foreign_key
|
||||
ADD CONSTRAINT table_for_foreign_key_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56897 (class 2606 OID 148993)
|
||||
-- Name: table_for_index table_for_index_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_index
|
||||
ADD CONSTRAINT table_for_index_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56908 (class 2606 OID 149151)
|
||||
-- Name: table_for_primary_key table_for_primary_key_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_primary_key
|
||||
ADD CONSTRAINT table_for_primary_key_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56902 (class 2606 OID 149041)
|
||||
-- Name: table_for_rule table_for_rule_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_rule
|
||||
ADD CONSTRAINT table_for_rule_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56900 (class 2606 OID 149020)
|
||||
-- Name: table_for_identical table_for_table_for_identical_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_identical
|
||||
ADD CONSTRAINT table_for_table_for_identical_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56904 (class 2606 OID 149073)
|
||||
-- Name: table_for_trigger table_for_trigger_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_trigger
|
||||
ADD CONSTRAINT table_for_trigger_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56893 (class 1259 OID 148994)
|
||||
-- Name: index1; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index1 ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56894 (class 1259 OID 148995)
|
||||
-- Name: index2; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index2 ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56898 (class 1259 OID 149021)
|
||||
-- Name: index_identical; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_identical ON target.table_for_identical USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56895 (class 1259 OID 149212)
|
||||
-- Name: index_same; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_same ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56892 (class 1259 OID 139945)
|
||||
-- Name: mview_index; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX mview_index ON target."MView" USING btree (text text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61045 (class 2618 OID 149042)
|
||||
-- Name: table_for_rule rule1; Type: RULE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule1 AS
|
||||
ON UPDATE TO target.table_for_rule DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61069 (class 0 OID 0)
|
||||
-- Dependencies: 61045
|
||||
-- Name: RULE rule1 ON table_for_rule; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON RULE rule1 ON target.table_for_rule IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61046 (class 2618 OID 149043)
|
||||
-- Name: table_for_rule rule2; Type: RULE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule2 AS
|
||||
ON UPDATE TO target.table_for_rule DO NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61047 (class 2618 OID 149044)
|
||||
-- Name: table_for_rule rule3; Type: RULE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule3 AS
|
||||
ON INSERT TO target.table_for_rule DO NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61050 (class 0 OID 139938)
|
||||
-- Dependencies: 12250 61062
|
||||
-- Name: MView; Type: MATERIALIZED VIEW DATA; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
REFRESH MATERIALIZED VIEW target."MView";
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12284 (class 1259 OID 347823)
|
||||
-- Name: test view; Type: VIEW; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW target."test view" AS
|
||||
SELECT pg_class.relname,
|
||||
pg_class.relnamespace,
|
||||
pg_class.reltype,
|
||||
pg_class.reloftype,
|
||||
pg_class.relowner,
|
||||
pg_class.relam,
|
||||
pg_class.relfilenode,
|
||||
pg_class.reltablespace,
|
||||
pg_class.relpages,
|
||||
pg_class.reltuples,
|
||||
pg_class.relallvisible,
|
||||
pg_class.reltoastrelid,
|
||||
pg_class.relhasindex,
|
||||
pg_class.relisshared,
|
||||
pg_class.relpersistence,
|
||||
pg_class.relkind,
|
||||
pg_class.relnatts,
|
||||
pg_class.relchecks,
|
||||
pg_class.relhasoids,
|
||||
pg_class.relhaspkey,
|
||||
pg_class.relhasrules,
|
||||
pg_class.relhastriggers,
|
||||
pg_class.relhassubclass,
|
||||
pg_class.relrowsecurity,
|
||||
pg_class.relforcerowsecurity,
|
||||
pg_class.relispopulated,
|
||||
pg_class.relreplident,
|
||||
pg_class.relispartition,
|
||||
pg_class.relfrozenxid,
|
||||
pg_class.relminmxid,
|
||||
pg_class.relacl,
|
||||
pg_class.reloptions,
|
||||
pg_class.relpartbound
|
||||
FROM pg_class
|
||||
LIMIT 10;
|
||||
|
||||
|
||||
ALTER TABLE target."test view" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12285 (class 1259 OID 347828)
|
||||
-- Name: test view f; Type: VIEW; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW target."test view f" WITH (security_barrier='true') AS
|
||||
SELECT 2;
|
||||
|
||||
|
||||
ALTER TABLE target."test view f" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61105 (class 0 OID 0)
|
||||
-- Dependencies: 12285
|
||||
-- Name: VIEW "test view f"; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON VIEW target."test view f" IS 'cmn';
|
439
web/pgadmin/tools/schema_diff/tests/pg/11_plus/source.sql
Normal file
439
web/pgadmin/tools/schema_diff/tests/pg/11_plus/source.sql
Normal file
@@ -0,0 +1,439 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.7
|
||||
-- Dumped by pg_dump version 12beta2
|
||||
|
||||
-- Started on 2019-11-01 12:54:15 IST
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- TOC entry 17 (class 2615 OID 139770)
|
||||
-- Name: source; Type: SCHEMA; Schema: -; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SCHEMA source;
|
||||
|
||||
|
||||
ALTER SCHEMA source OWNER TO postgres;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA source;
|
||||
|
||||
--
|
||||
-- TOC entry 12272 (class 1259 OID 149205)
|
||||
-- Name: table_for_partition; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_partition (
|
||||
col1 bigint NOT NULL
|
||||
)
|
||||
PARTITION BY RANGE (col1);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_partition OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12273 (class 1259 OID 149208)
|
||||
-- Name: part1; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.part1 (
|
||||
col1 bigint NOT NULL
|
||||
);
|
||||
ALTER TABLE ONLY source.table_for_partition ATTACH PARTITION source.part1 FOR VALUES FROM ('1') TO ('23');
|
||||
|
||||
|
||||
ALTER TABLE source.part1 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12274 (class 1259 OID 149213)
|
||||
-- Name: table_for_partition_1; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_partition_1 (
|
||||
col1 bigint
|
||||
)
|
||||
PARTITION BY RANGE (col1);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_partition_1 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12275 (class 1259 OID 149216)
|
||||
-- Name: part3; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.part3 (
|
||||
col1 bigint
|
||||
);
|
||||
ALTER TABLE ONLY source.table_for_partition_1 ATTACH PARTITION source.part3 FOR VALUES FROM ('1') TO ('10');
|
||||
|
||||
|
||||
ALTER TABLE source.part3 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12276 (class 1259 OID 149219)
|
||||
-- Name: part4; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.part4 (
|
||||
col1 bigint
|
||||
);
|
||||
ALTER TABLE ONLY source.table_for_partition_1 ATTACH PARTITION source.part4 FOR VALUES FROM ('11') TO ('20');
|
||||
|
||||
|
||||
ALTER TABLE source.part4 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12258 (class 1259 OID 148963)
|
||||
-- Name: table_for_column; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_column (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text,
|
||||
col3 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_column OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12256 (class 1259 OID 148895)
|
||||
-- Name: table_for_constraints; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_constraints (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_constraints OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61066 (class 0 OID 0)
|
||||
-- Dependencies: 12256
|
||||
-- Name: TABLE table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON TABLE source.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12262 (class 1259 OID 149004)
|
||||
-- Name: table_for_identical; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_identical (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_identical OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12260 (class 1259 OID 148977)
|
||||
-- Name: table_for_index; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_index (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_index OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12269 (class 1259 OID 149128)
|
||||
-- Name: table_for_primary_key; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_primary_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_primary_key OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12264 (class 1259 OID 149024)
|
||||
-- Name: table_for_rule; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_rule (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_rule OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12266 (class 1259 OID 149048)
|
||||
-- Name: table_for_trigger; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_trigger (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_trigger OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 56893 (class 2606 OID 148904)
|
||||
-- Name: table_for_constraints Exclusion; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT "Exclusion" EXCLUDE USING gist (col2 WITH <>) WITH (fillfactor='12') WHERE ((col1 > 1)) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61067 (class 0 OID 0)
|
||||
-- Dependencies: 56893
|
||||
-- Name: CONSTRAINT "Exclusion" ON table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "Exclusion" ON source.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56891 (class 2606 OID 148911)
|
||||
-- Name: table_for_constraints check_con; Type: CHECK CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE source.table_for_constraints
|
||||
ADD CONSTRAINT check_con CHECK ((col1 > 10)) NOT VALID;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61068 (class 0 OID 0)
|
||||
-- Dependencies: 56891
|
||||
-- Name: CONSTRAINT check_con ON table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT check_con ON source.table_for_constraints IS 'coment';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56899 (class 2606 OID 148970)
|
||||
-- Name: table_for_column table_for_column_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_column
|
||||
ADD CONSTRAINT table_for_column_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56895 (class 2606 OID 148902)
|
||||
-- Name: table_for_constraints table_for_constraints_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT table_for_constraints_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56904 (class 2606 OID 148984)
|
||||
-- Name: table_for_index table_for_index_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_index
|
||||
ADD CONSTRAINT table_for_index_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56913 (class 2606 OID 149135)
|
||||
-- Name: table_for_primary_key table_for_primary_key_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_primary_key
|
||||
ADD CONSTRAINT table_for_primary_key_pkey PRIMARY KEY (col1, col2);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56909 (class 2606 OID 149031)
|
||||
-- Name: table_for_rule table_for_rule_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_rule
|
||||
ADD CONSTRAINT table_for_rule_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56907 (class 2606 OID 149011)
|
||||
-- Name: table_for_identical table_for_table_for_identical_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_identical
|
||||
ADD CONSTRAINT table_for_table_for_identical_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56911 (class 2606 OID 149055)
|
||||
-- Name: table_for_trigger table_for_trigger_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_trigger
|
||||
ADD CONSTRAINT table_for_trigger_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56897 (class 2606 OID 148913)
|
||||
-- Name: table_for_constraints unique; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT "unique" UNIQUE (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61069 (class 0 OID 0)
|
||||
-- Dependencies: 56897
|
||||
-- Name: CONSTRAINT "unique" ON table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "unique" ON source.table_for_constraints IS 'cmnt';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56900 (class 1259 OID 149023)
|
||||
-- Name: index1; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index1 ON source.table_for_index USING btree (col2 varchar_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56905 (class 1259 OID 149012)
|
||||
-- Name: index_identical; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_identical ON source.table_for_identical USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56901 (class 1259 OID 149211)
|
||||
-- Name: index_same; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_same ON source.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56902 (class 1259 OID 149022)
|
||||
-- Name: index_source; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_source ON source.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61044 (class 2618 OID 149032)
|
||||
-- Name: table_for_rule rule1; Type: RULE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule1 AS
|
||||
ON UPDATE TO source.table_for_rule DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61070 (class 0 OID 0)
|
||||
-- Dependencies: 61044
|
||||
-- Name: RULE rule1 ON table_for_rule; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON RULE rule1 ON source.table_for_rule IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61045 (class 2618 OID 149033)
|
||||
-- Name: table_for_rule rule2; Type: RULE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule2 AS
|
||||
ON INSERT TO source.table_for_rule DO NOTHING;
|
||||
|
||||
--
|
||||
-- TOC entry 12283 (class 1259 OID 347818)
|
||||
-- Name: test view; Type: VIEW; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW source."test view" AS
|
||||
SELECT pg_class.relname,
|
||||
pg_class.relnamespace,
|
||||
pg_class.reltype,
|
||||
pg_class.reloftype,
|
||||
pg_class.relowner,
|
||||
pg_class.relam,
|
||||
pg_class.relfilenode,
|
||||
pg_class.reltablespace,
|
||||
pg_class.relpages,
|
||||
pg_class.reltuples,
|
||||
pg_class.relallvisible,
|
||||
pg_class.reltoastrelid,
|
||||
pg_class.relhasindex,
|
||||
pg_class.relisshared,
|
||||
pg_class.relpersistence,
|
||||
pg_class.relkind,
|
||||
pg_class.relnatts,
|
||||
pg_class.relchecks,
|
||||
pg_class.relhasoids,
|
||||
pg_class.relhasrules,
|
||||
pg_class.relhastriggers,
|
||||
pg_class.relhassubclass,
|
||||
pg_class.relrowsecurity,
|
||||
pg_class.relforcerowsecurity,
|
||||
pg_class.relispopulated,
|
||||
pg_class.relreplident,
|
||||
pg_class.relispartition,
|
||||
pg_class.relfrozenxid,
|
||||
pg_class.relminmxid,
|
||||
pg_class.relacl,
|
||||
pg_class.reloptions,
|
||||
pg_class.relpartbound
|
||||
FROM pg_class
|
||||
LIMIT 10;
|
||||
|
||||
|
||||
ALTER TABLE source."test view" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12286 (class 1259 OID 347832)
|
||||
-- Name: test view f; Type: VIEW; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW source."test view f" WITH (security_barrier='false') AS
|
||||
SELECT 2;
|
||||
|
||||
|
||||
ALTER TABLE source."test view f" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61111 (class 0 OID 0)
|
||||
-- Dependencies: 12286
|
||||
-- Name: VIEW "test view f"; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON VIEW source."test view f" IS 'cmn';
|
428
web/pgadmin/tools/schema_diff/tests/pg/11_plus/target.sql
Normal file
428
web/pgadmin/tools/schema_diff/tests/pg/11_plus/target.sql
Normal file
@@ -0,0 +1,428 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.7
|
||||
-- Dumped by pg_dump version 12beta2
|
||||
|
||||
-- Started on 2019-11-01 12:55:22 IST
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- TOC entry 18 (class 2615 OID 139771)
|
||||
-- Name: target; Type: SCHEMA; Schema: -; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SCHEMA target;
|
||||
|
||||
ALTER SCHEMA target OWNER TO postgres;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA target;
|
||||
|
||||
--
|
||||
-- TOC entry 12250 (class 1259 OID 139938)
|
||||
-- Name: MView; Type: MATERIALIZED VIEW; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE MATERIALIZED VIEW target."MView" AS
|
||||
SELECT 'tekst'::text AS text
|
||||
WITH NO DATA;
|
||||
|
||||
|
||||
ALTER TABLE target."MView" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12277 (class 1259 OID 149234)
|
||||
-- Name: table_for_partition_1; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_partition_1 (
|
||||
col1 bigint
|
||||
)
|
||||
PARTITION BY RANGE (col1);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_partition_1 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12278 (class 1259 OID 149237)
|
||||
-- Name: part3; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.part3 (
|
||||
col1 bigint
|
||||
);
|
||||
ALTER TABLE ONLY target.table_for_partition_1 ATTACH PARTITION target.part3 FOR VALUES FROM ('13') TO ('56');
|
||||
|
||||
|
||||
ALTER TABLE target.part3 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12259 (class 1259 OID 148971)
|
||||
-- Name: table_for_column; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_column (
|
||||
col1 bigint,
|
||||
col2 bigint,
|
||||
col4 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_column OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12268 (class 1259 OID 149089)
|
||||
-- Name: table_for_constraints; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_constraints (
|
||||
col1 integer NOT NULL,
|
||||
col2 text,
|
||||
CONSTRAINT check_con CHECK ((col1 > 30))
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_constraints OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61066 (class 0 OID 0)
|
||||
-- Dependencies: 12268
|
||||
-- Name: TABLE table_for_constraints; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON TABLE target.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61067 (class 0 OID 0)
|
||||
-- Dependencies: 12268
|
||||
-- Name: CONSTRAINT check_con ON table_for_constraints; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT check_con ON target.table_for_constraints IS 'coment';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12257 (class 1259 OID 148960)
|
||||
-- Name: table_for_del; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_del (
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_del OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12271 (class 1259 OID 149172)
|
||||
-- Name: table_for_foreign_key; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_foreign_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 "char",
|
||||
col3 bigint
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_foreign_key OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12263 (class 1259 OID 149013)
|
||||
-- Name: table_for_identical; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_identical (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_identical OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12261 (class 1259 OID 148986)
|
||||
-- Name: table_for_index; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_index (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_index OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12270 (class 1259 OID 149144)
|
||||
-- Name: table_for_primary_key; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_primary_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_primary_key OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12265 (class 1259 OID 149034)
|
||||
-- Name: table_for_rule; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_rule (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_rule OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12267 (class 1259 OID 149066)
|
||||
-- Name: table_for_trigger; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_trigger (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_trigger OWNER TO postgres;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56906 (class 2606 OID 149097)
|
||||
-- Name: table_for_constraints Exclusion; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_constraints
|
||||
ADD CONSTRAINT "Exclusion" EXCLUDE USING gist (col2 WITH <>) WITH (fillfactor='15') WHERE ((col1 > 1)) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61068 (class 0 OID 0)
|
||||
-- Dependencies: 56906
|
||||
-- Name: CONSTRAINT "Exclusion" ON table_for_constraints; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "Exclusion" ON target.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56910 (class 2606 OID 149176)
|
||||
-- Name: table_for_foreign_key table_for_foreign_key_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_foreign_key
|
||||
ADD CONSTRAINT table_for_foreign_key_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56897 (class 2606 OID 148993)
|
||||
-- Name: table_for_index table_for_index_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_index
|
||||
ADD CONSTRAINT table_for_index_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56908 (class 2606 OID 149151)
|
||||
-- Name: table_for_primary_key table_for_primary_key_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_primary_key
|
||||
ADD CONSTRAINT table_for_primary_key_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56902 (class 2606 OID 149041)
|
||||
-- Name: table_for_rule table_for_rule_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_rule
|
||||
ADD CONSTRAINT table_for_rule_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56900 (class 2606 OID 149020)
|
||||
-- Name: table_for_identical table_for_table_for_identical_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_identical
|
||||
ADD CONSTRAINT table_for_table_for_identical_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56904 (class 2606 OID 149073)
|
||||
-- Name: table_for_trigger table_for_trigger_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_trigger
|
||||
ADD CONSTRAINT table_for_trigger_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56893 (class 1259 OID 148994)
|
||||
-- Name: index1; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index1 ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56894 (class 1259 OID 148995)
|
||||
-- Name: index2; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index2 ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56898 (class 1259 OID 149021)
|
||||
-- Name: index_identical; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_identical ON target.table_for_identical USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56895 (class 1259 OID 149212)
|
||||
-- Name: index_same; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_same ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56892 (class 1259 OID 139945)
|
||||
-- Name: mview_index; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX mview_index ON target."MView" USING btree (text text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61045 (class 2618 OID 149042)
|
||||
-- Name: table_for_rule rule1; Type: RULE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule1 AS
|
||||
ON UPDATE TO target.table_for_rule DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61069 (class 0 OID 0)
|
||||
-- Dependencies: 61045
|
||||
-- Name: RULE rule1 ON table_for_rule; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON RULE rule1 ON target.table_for_rule IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61046 (class 2618 OID 149043)
|
||||
-- Name: table_for_rule rule2; Type: RULE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule2 AS
|
||||
ON UPDATE TO target.table_for_rule DO NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61047 (class 2618 OID 149044)
|
||||
-- Name: table_for_rule rule3; Type: RULE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule3 AS
|
||||
ON INSERT TO target.table_for_rule DO NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61050 (class 0 OID 139938)
|
||||
-- Dependencies: 12250 61062
|
||||
-- Name: MView; Type: MATERIALIZED VIEW DATA; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
REFRESH MATERIALIZED VIEW target."MView";
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12284 (class 1259 OID 347823)
|
||||
-- Name: test view; Type: VIEW; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW target."test view" AS
|
||||
SELECT pg_class.relname,
|
||||
pg_class.relnamespace,
|
||||
pg_class.reltype,
|
||||
pg_class.reloftype,
|
||||
pg_class.relowner,
|
||||
pg_class.relam,
|
||||
pg_class.relfilenode,
|
||||
pg_class.reltablespace,
|
||||
pg_class.relpages,
|
||||
pg_class.reltuples,
|
||||
pg_class.relallvisible,
|
||||
pg_class.reltoastrelid,
|
||||
pg_class.relhasindex,
|
||||
pg_class.relisshared,
|
||||
pg_class.relpersistence,
|
||||
pg_class.relkind,
|
||||
pg_class.relnatts,
|
||||
pg_class.relchecks,
|
||||
pg_class.relhasoids,
|
||||
pg_class.relhasrules,
|
||||
pg_class.relhastriggers,
|
||||
pg_class.relhassubclass,
|
||||
pg_class.relrowsecurity,
|
||||
pg_class.relforcerowsecurity,
|
||||
pg_class.relispopulated,
|
||||
pg_class.relreplident,
|
||||
pg_class.relispartition,
|
||||
pg_class.relfrozenxid,
|
||||
pg_class.relminmxid,
|
||||
pg_class.relacl,
|
||||
pg_class.reloptions,
|
||||
pg_class.relpartbound
|
||||
FROM pg_class
|
||||
LIMIT 10;
|
||||
|
||||
|
||||
ALTER TABLE target."test view" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12285 (class 1259 OID 347828)
|
||||
-- Name: test view f; Type: VIEW; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW target."test view f" WITH (security_barrier='true') AS
|
||||
SELECT 2;
|
||||
|
||||
|
||||
ALTER TABLE target."test view f" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61105 (class 0 OID 0)
|
||||
-- Dependencies: 12285
|
||||
-- Name: VIEW "test view f"; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON VIEW target."test view f" IS 'cmn';
|
440
web/pgadmin/tools/schema_diff/tests/pg/12_plus/source.sql
Normal file
440
web/pgadmin/tools/schema_diff/tests/pg/12_plus/source.sql
Normal file
@@ -0,0 +1,440 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.7
|
||||
-- Dumped by pg_dump version 12beta2
|
||||
|
||||
-- Started on 2019-11-01 12:54:15 IST
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- TOC entry 17 (class 2615 OID 139770)
|
||||
-- Name: source; Type: SCHEMA; Schema: -; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SCHEMA source;
|
||||
|
||||
|
||||
ALTER SCHEMA source OWNER TO postgres;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA source;
|
||||
|
||||
--
|
||||
-- TOC entry 12272 (class 1259 OID 149205)
|
||||
-- Name: table_for_partition; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_partition (
|
||||
col1 bigint NOT NULL
|
||||
)
|
||||
PARTITION BY RANGE (col1);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_partition OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12273 (class 1259 OID 149208)
|
||||
-- Name: part1; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.part1 (
|
||||
col1 bigint NOT NULL
|
||||
);
|
||||
ALTER TABLE ONLY source.table_for_partition ATTACH PARTITION source.part1 FOR VALUES FROM ('1') TO ('23');
|
||||
|
||||
|
||||
ALTER TABLE source.part1 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12274 (class 1259 OID 149213)
|
||||
-- Name: table_for_partition_1; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_partition_1 (
|
||||
col1 bigint
|
||||
)
|
||||
PARTITION BY RANGE (col1);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_partition_1 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12275 (class 1259 OID 149216)
|
||||
-- Name: part3; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.part3 (
|
||||
col1 bigint
|
||||
);
|
||||
ALTER TABLE ONLY source.table_for_partition_1 ATTACH PARTITION source.part3 FOR VALUES FROM ('1') TO ('10');
|
||||
|
||||
|
||||
ALTER TABLE source.part3 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12276 (class 1259 OID 149219)
|
||||
-- Name: part4; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.part4 (
|
||||
col1 bigint
|
||||
);
|
||||
ALTER TABLE ONLY source.table_for_partition_1 ATTACH PARTITION source.part4 FOR VALUES FROM ('11') TO ('20');
|
||||
|
||||
|
||||
ALTER TABLE source.part4 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12258 (class 1259 OID 148963)
|
||||
-- Name: table_for_column; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_column (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text,
|
||||
col3 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_column OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12256 (class 1259 OID 148895)
|
||||
-- Name: table_for_constraints; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_constraints (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_constraints OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61066 (class 0 OID 0)
|
||||
-- Dependencies: 12256
|
||||
-- Name: TABLE table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON TABLE source.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12262 (class 1259 OID 149004)
|
||||
-- Name: table_for_identical; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_identical (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_identical OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12260 (class 1259 OID 148977)
|
||||
-- Name: table_for_index; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_index (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_index OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12269 (class 1259 OID 149128)
|
||||
-- Name: table_for_primary_key; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_primary_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_primary_key OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12264 (class 1259 OID 149024)
|
||||
-- Name: table_for_rule; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_rule (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_rule OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12266 (class 1259 OID 149048)
|
||||
-- Name: table_for_trigger; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_trigger (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_trigger OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 56893 (class 2606 OID 148904)
|
||||
-- Name: table_for_constraints Exclusion; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT "Exclusion" EXCLUDE USING gist (col2 WITH <>) WITH (fillfactor='12') WHERE ((col1 > 1)) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61067 (class 0 OID 0)
|
||||
-- Dependencies: 56893
|
||||
-- Name: CONSTRAINT "Exclusion" ON table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "Exclusion" ON source.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56891 (class 2606 OID 148911)
|
||||
-- Name: table_for_constraints check_con; Type: CHECK CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE source.table_for_constraints
|
||||
ADD CONSTRAINT check_con CHECK ((col1 > 10)) NOT VALID;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61068 (class 0 OID 0)
|
||||
-- Dependencies: 56891
|
||||
-- Name: CONSTRAINT check_con ON table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT check_con ON source.table_for_constraints IS 'coment';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56899 (class 2606 OID 148970)
|
||||
-- Name: table_for_column table_for_column_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_column
|
||||
ADD CONSTRAINT table_for_column_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56895 (class 2606 OID 148902)
|
||||
-- Name: table_for_constraints table_for_constraints_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT table_for_constraints_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56904 (class 2606 OID 148984)
|
||||
-- Name: table_for_index table_for_index_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_index
|
||||
ADD CONSTRAINT table_for_index_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56913 (class 2606 OID 149135)
|
||||
-- Name: table_for_primary_key table_for_primary_key_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_primary_key
|
||||
ADD CONSTRAINT table_for_primary_key_pkey PRIMARY KEY (col1, col2);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56909 (class 2606 OID 149031)
|
||||
-- Name: table_for_rule table_for_rule_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_rule
|
||||
ADD CONSTRAINT table_for_rule_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56907 (class 2606 OID 149011)
|
||||
-- Name: table_for_identical table_for_table_for_identical_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_identical
|
||||
ADD CONSTRAINT table_for_table_for_identical_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56911 (class 2606 OID 149055)
|
||||
-- Name: table_for_trigger table_for_trigger_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_trigger
|
||||
ADD CONSTRAINT table_for_trigger_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56897 (class 2606 OID 148913)
|
||||
-- Name: table_for_constraints unique; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT "unique" UNIQUE (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61069 (class 0 OID 0)
|
||||
-- Dependencies: 56897
|
||||
-- Name: CONSTRAINT "unique" ON table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "unique" ON source.table_for_constraints IS 'cmnt';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56900 (class 1259 OID 149023)
|
||||
-- Name: index1; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index1 ON source.table_for_index USING btree (col2 varchar_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56905 (class 1259 OID 149012)
|
||||
-- Name: index_identical; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_identical ON source.table_for_identical USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56901 (class 1259 OID 149211)
|
||||
-- Name: index_same; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_same ON source.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56902 (class 1259 OID 149022)
|
||||
-- Name: index_source; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_source ON source.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61044 (class 2618 OID 149032)
|
||||
-- Name: table_for_rule rule1; Type: RULE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule1 AS
|
||||
ON UPDATE TO source.table_for_rule DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61070 (class 0 OID 0)
|
||||
-- Dependencies: 61044
|
||||
-- Name: RULE rule1 ON table_for_rule; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON RULE rule1 ON source.table_for_rule IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61045 (class 2618 OID 149033)
|
||||
-- Name: table_for_rule rule2; Type: RULE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule2 AS
|
||||
ON INSERT TO source.table_for_rule DO NOTHING;
|
||||
|
||||
--
|
||||
-- TOC entry 12283 (class 1259 OID 347818)
|
||||
-- Name: test view; Type: VIEW; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW source."test view" AS
|
||||
SELECT pg_class.relname,
|
||||
pg_class.relnamespace,
|
||||
pg_class.reltype,
|
||||
pg_class.reloftype,
|
||||
pg_class.relowner,
|
||||
pg_class.relam,
|
||||
pg_class.relfilenode,
|
||||
pg_class.reltablespace,
|
||||
pg_class.relpages
|
||||
FROM pg_class
|
||||
LIMIT 10;
|
||||
|
||||
|
||||
ALTER TABLE source."test view" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12286 (class 1259 OID 347832)
|
||||
-- Name: test view f; Type: VIEW; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW source."test view f" WITH (security_barrier='false') AS
|
||||
SELECT 2;
|
||||
|
||||
|
||||
ALTER TABLE source."test view f" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61111 (class 0 OID 0)
|
||||
-- Dependencies: 12286
|
||||
-- Name: VIEW "test view f"; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON VIEW source."test view f" IS 'cmn';
|
||||
|
||||
--
|
||||
-- TOC entry 223 (class 1255 OID 67206)
|
||||
-- Name: dodaj_klijenta(character varying, character varying, character varying, character varying, integer, character varying, character varying, character varying, boolean, boolean, character varying, character varying, character varying, character varying, numeric, character varying); Type: PROCEDURE; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE PROCEDURE source.dodaj_klijenta(v_naziv character varying, v_oib character varying, v_pdv_id character varying, v_adresa character varying, v_mjesto integer, v_drzava character varying, v_tip_p_sub character varying, v_vlasnik character varying, v_pdv boolean, v_fisk boolean, v_iban character varying, v_k_osoba character varying, v_email character varying, v_br_tel character varying, v_radna_god numeric, v_schema character varying)
|
||||
LANGUAGE sql
|
||||
AS $$select 1;$$;
|
||||
|
||||
|
||||
ALTER PROCEDURE source.dodaj_klijenta(v_naziv character varying, v_oib character varying, v_pdv_id character varying, v_adresa character varying, v_mjesto integer, v_drzava character varying, v_tip_p_sub character varying, v_vlasnik character varying, v_pdv boolean, v_fisk boolean, v_iban character varying, v_k_osoba character varying, v_email character varying, v_br_tel character varying, v_radna_god numeric, v_schema character varying) OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 220 (class 1255 OID 67205)
|
||||
-- Name: proc1(bigint); Type: PROCEDURE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE PROCEDURE source.proc1(arg1 bigint)
|
||||
LANGUAGE sql
|
||||
AS $$select 1;$$;
|
||||
|
||||
|
||||
ALTER PROCEDURE source.proc1(arg1 bigint) OWNER TO postgres;
|
417
web/pgadmin/tools/schema_diff/tests/pg/12_plus/target.sql
Normal file
417
web/pgadmin/tools/schema_diff/tests/pg/12_plus/target.sql
Normal file
@@ -0,0 +1,417 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.7
|
||||
-- Dumped by pg_dump version 12beta2
|
||||
|
||||
-- Started on 2019-11-01 12:55:22 IST
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- TOC entry 18 (class 2615 OID 139771)
|
||||
-- Name: target; Type: SCHEMA; Schema: -; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SCHEMA target;
|
||||
|
||||
ALTER SCHEMA target OWNER TO postgres;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA target;
|
||||
|
||||
--
|
||||
-- TOC entry 12250 (class 1259 OID 139938)
|
||||
-- Name: MView; Type: MATERIALIZED VIEW; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE MATERIALIZED VIEW target."MView" AS
|
||||
SELECT 'tekst'::text AS text
|
||||
WITH NO DATA;
|
||||
|
||||
|
||||
ALTER TABLE target."MView" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12277 (class 1259 OID 149234)
|
||||
-- Name: table_for_partition_1; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_partition_1 (
|
||||
col1 bigint
|
||||
)
|
||||
PARTITION BY RANGE (col1);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_partition_1 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12278 (class 1259 OID 149237)
|
||||
-- Name: part3; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.part3 (
|
||||
col1 bigint
|
||||
);
|
||||
ALTER TABLE ONLY target.table_for_partition_1 ATTACH PARTITION target.part3 FOR VALUES FROM ('13') TO ('56');
|
||||
|
||||
|
||||
ALTER TABLE target.part3 OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12259 (class 1259 OID 148971)
|
||||
-- Name: table_for_column; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_column (
|
||||
col1 bigint,
|
||||
col2 bigint,
|
||||
col4 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_column OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12268 (class 1259 OID 149089)
|
||||
-- Name: table_for_constraints; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_constraints (
|
||||
col1 integer NOT NULL,
|
||||
col2 text,
|
||||
CONSTRAINT check_con CHECK ((col1 > 30))
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_constraints OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61066 (class 0 OID 0)
|
||||
-- Dependencies: 12268
|
||||
-- Name: TABLE table_for_constraints; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON TABLE target.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61067 (class 0 OID 0)
|
||||
-- Dependencies: 12268
|
||||
-- Name: CONSTRAINT check_con ON table_for_constraints; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT check_con ON target.table_for_constraints IS 'coment';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12257 (class 1259 OID 148960)
|
||||
-- Name: table_for_del; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_del (
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_del OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12271 (class 1259 OID 149172)
|
||||
-- Name: table_for_foreign_key; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_foreign_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 "char",
|
||||
col3 bigint
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_foreign_key OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12263 (class 1259 OID 149013)
|
||||
-- Name: table_for_identical; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_identical (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_identical OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12261 (class 1259 OID 148986)
|
||||
-- Name: table_for_index; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_index (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_index OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12270 (class 1259 OID 149144)
|
||||
-- Name: table_for_primary_key; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_primary_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_primary_key OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12265 (class 1259 OID 149034)
|
||||
-- Name: table_for_rule; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_rule (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_rule OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12267 (class 1259 OID 149066)
|
||||
-- Name: table_for_trigger; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_trigger (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_trigger OWNER TO postgres;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56906 (class 2606 OID 149097)
|
||||
-- Name: table_for_constraints Exclusion; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_constraints
|
||||
ADD CONSTRAINT "Exclusion" EXCLUDE USING gist (col2 WITH <>) WITH (fillfactor='15') WHERE ((col1 > 1)) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61068 (class 0 OID 0)
|
||||
-- Dependencies: 56906
|
||||
-- Name: CONSTRAINT "Exclusion" ON table_for_constraints; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "Exclusion" ON target.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56910 (class 2606 OID 149176)
|
||||
-- Name: table_for_foreign_key table_for_foreign_key_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_foreign_key
|
||||
ADD CONSTRAINT table_for_foreign_key_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56897 (class 2606 OID 148993)
|
||||
-- Name: table_for_index table_for_index_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_index
|
||||
ADD CONSTRAINT table_for_index_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56908 (class 2606 OID 149151)
|
||||
-- Name: table_for_primary_key table_for_primary_key_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_primary_key
|
||||
ADD CONSTRAINT table_for_primary_key_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56902 (class 2606 OID 149041)
|
||||
-- Name: table_for_rule table_for_rule_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_rule
|
||||
ADD CONSTRAINT table_for_rule_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56900 (class 2606 OID 149020)
|
||||
-- Name: table_for_identical table_for_table_for_identical_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_identical
|
||||
ADD CONSTRAINT table_for_table_for_identical_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56904 (class 2606 OID 149073)
|
||||
-- Name: table_for_trigger table_for_trigger_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_trigger
|
||||
ADD CONSTRAINT table_for_trigger_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56893 (class 1259 OID 148994)
|
||||
-- Name: index1; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index1 ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56894 (class 1259 OID 148995)
|
||||
-- Name: index2; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index2 ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56898 (class 1259 OID 149021)
|
||||
-- Name: index_identical; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_identical ON target.table_for_identical USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56895 (class 1259 OID 149212)
|
||||
-- Name: index_same; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_same ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56892 (class 1259 OID 139945)
|
||||
-- Name: mview_index; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX mview_index ON target."MView" USING btree (text text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61045 (class 2618 OID 149042)
|
||||
-- Name: table_for_rule rule1; Type: RULE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule1 AS
|
||||
ON UPDATE TO target.table_for_rule DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61069 (class 0 OID 0)
|
||||
-- Dependencies: 61045
|
||||
-- Name: RULE rule1 ON table_for_rule; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON RULE rule1 ON target.table_for_rule IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61046 (class 2618 OID 149043)
|
||||
-- Name: table_for_rule rule2; Type: RULE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule2 AS
|
||||
ON UPDATE TO target.table_for_rule DO NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61047 (class 2618 OID 149044)
|
||||
-- Name: table_for_rule rule3; Type: RULE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule3 AS
|
||||
ON INSERT TO target.table_for_rule DO NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61050 (class 0 OID 139938)
|
||||
-- Dependencies: 12250 61062
|
||||
-- Name: MView; Type: MATERIALIZED VIEW DATA; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
REFRESH MATERIALIZED VIEW target."MView";
|
||||
|
||||
--
|
||||
-- TOC entry 12284 (class 1259 OID 347823)
|
||||
-- Name: test view; Type: VIEW; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW target."test view" AS
|
||||
SELECT pg_class.relname,
|
||||
pg_class.relnamespace,
|
||||
pg_class.reltype,
|
||||
pg_class.reloftype,
|
||||
pg_class.relowner,
|
||||
pg_class.relam,
|
||||
pg_class.relfilenode,
|
||||
pg_class.reltablespace,
|
||||
pg_class.relpages
|
||||
FROM pg_class
|
||||
LIMIT 10;
|
||||
|
||||
|
||||
ALTER TABLE target."test view" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12285 (class 1259 OID 347828)
|
||||
-- Name: test view f; Type: VIEW; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE VIEW target."test view f" WITH (security_barrier='true') AS
|
||||
SELECT 2;
|
||||
|
||||
|
||||
ALTER TABLE target."test view f" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61105 (class 0 OID 0)
|
||||
-- Dependencies: 12285
|
||||
-- Name: VIEW "test view f"; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON VIEW target."test view f" IS 'cmn';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 437 (class 1255 OID 112907)
|
||||
-- Name: dodaj_klijenta(character varying, character varying, character varying, character varying, integer, character varying, character varying, character varying, boolean, boolean, character varying, character varying, character varying, character varying, numeric, character varying); Type: PROCEDURE; Schema: target schema; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE PROCEDURE target.dodaj_klijenta(v_naziv character varying, v_oib character varying, v_pdv_id character varying, v_adresa character varying, v_mjesto integer, v_drzava character varying, v_tip_p_sub character varying, v_vlasnik character varying, v_pdv boolean, v_fisk boolean, v_iban character varying, v_k_osoba character varying, v_email character varying, v_br_tel character varying, v_radna_god numeric, v_schema character varying)
|
||||
LANGUAGE sql
|
||||
AS $$select 4;$$;
|
||||
|
||||
|
||||
ALTER PROCEDURE target.dodaj_klijenta(v_naziv character varying, v_oib character varying, v_pdv_id character varying, v_adresa character varying, v_mjesto integer, v_drzava character varying, v_tip_p_sub character varying, v_vlasnik character varying, v_pdv boolean, v_fisk boolean, v_iban character varying, v_k_osoba character varying, v_email character varying, v_br_tel character varying, v_radna_god numeric, v_schema character varying) OWNER TO postgres;
|
311
web/pgadmin/tools/schema_diff/tests/pg/9.2_plus/source.sql
Normal file
311
web/pgadmin/tools/schema_diff/tests/pg/9.2_plus/source.sql
Normal file
@@ -0,0 +1,311 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.7
|
||||
-- Dumped by pg_dump version 12beta2
|
||||
|
||||
-- Started on 2019-11-01 12:54:15 IST
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
|
||||
--
|
||||
-- TOC entry 17 (class 2615 OID 139770)
|
||||
-- Name: source; Type: SCHEMA; Schema: -; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SCHEMA source;
|
||||
|
||||
|
||||
ALTER SCHEMA source OWNER TO postgres;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA source;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12258 (class 1259 OID 148963)
|
||||
-- Name: table_for_column; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_column (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text,
|
||||
col3 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_column OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12256 (class 1259 OID 148895)
|
||||
-- Name: table_for_constraints; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_constraints (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_constraints OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61066 (class 0 OID 0)
|
||||
-- Dependencies: 12256
|
||||
-- Name: TABLE table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON TABLE source.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12262 (class 1259 OID 149004)
|
||||
-- Name: table_for_identical; Type: TABLE; Schema: source; Owner: postgres;
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_identical (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_identical OWNER TO postgres;;
|
||||
|
||||
--
|
||||
-- TOC entry 12260 (class 1259 OID 148977)
|
||||
-- Name: table_for_index; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_index (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_index OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12269 (class 1259 OID 149128)
|
||||
-- Name: table_for_primary_key; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_primary_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_primary_key OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12264 (class 1259 OID 149024)
|
||||
-- Name: table_for_rule; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_rule (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_rule OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12266 (class 1259 OID 149048)
|
||||
-- Name: table_for_trigger; Type: TABLE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_trigger (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_trigger OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 56893 (class 2606 OID 148904)
|
||||
-- Name: table_for_constraints Exclusion; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT "Exclusion" EXCLUDE USING gist (col2 WITH <>) WITH (fillfactor='12') WHERE ((col1 > 1)) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61067 (class 0 OID 0)
|
||||
-- Dependencies: 56893
|
||||
-- Name: CONSTRAINT "Exclusion" ON table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "Exclusion" ON source.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56891 (class 2606 OID 148911)
|
||||
-- Name: table_for_constraints check_con; Type: CHECK CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE source.table_for_constraints
|
||||
ADD CONSTRAINT check_con CHECK ((col1 > 10)) NOT VALID;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61068 (class 0 OID 0)
|
||||
-- Dependencies: 56891
|
||||
-- Name: CONSTRAINT check_con ON table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT check_con ON source.table_for_constraints IS 'coment';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56899 (class 2606 OID 148970)
|
||||
-- Name: table_for_column table_for_column_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_column
|
||||
ADD CONSTRAINT table_for_column_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56895 (class 2606 OID 148902)
|
||||
-- Name: table_for_constraints table_for_constraints_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT table_for_constraints_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56904 (class 2606 OID 148984)
|
||||
-- Name: table_for_index table_for_index_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_index
|
||||
ADD CONSTRAINT table_for_index_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56913 (class 2606 OID 149135)
|
||||
-- Name: table_for_primary_key table_for_primary_key_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_primary_key
|
||||
ADD CONSTRAINT table_for_primary_key_pkey PRIMARY KEY (col1, col2);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56909 (class 2606 OID 149031)
|
||||
-- Name: table_for_rule table_for_rule_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_rule
|
||||
ADD CONSTRAINT table_for_rule_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56907 (class 2606 OID 149011)
|
||||
-- Name: table_for_identical table_for_table_for_identical_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres;
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_identical
|
||||
ADD CONSTRAINT table_for_table_for_identical_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56911 (class 2606 OID 149055)
|
||||
-- Name: table_for_trigger table_for_trigger_pkey; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_trigger
|
||||
ADD CONSTRAINT table_for_trigger_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56897 (class 2606 OID 148913)
|
||||
-- Name: table_for_constraints unique; Type: CONSTRAINT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT "unique" UNIQUE (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61069 (class 0 OID 0)
|
||||
-- Dependencies: 56897
|
||||
-- Name: CONSTRAINT "unique" ON table_for_constraints; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "unique" ON source.table_for_constraints IS 'cmnt';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56900 (class 1259 OID 149023)
|
||||
-- Name: index1; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index1 ON source.table_for_index USING btree (col2 varchar_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56905 (class 1259 OID 149012)
|
||||
-- Name: index_identical; Type: INDEX; Schema: source; Owner: postgres;
|
||||
--
|
||||
|
||||
CREATE INDEX index_identical ON source.table_for_identical USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56901 (class 1259 OID 149211)
|
||||
-- Name: index_same; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_same ON source.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56902 (class 1259 OID 149022)
|
||||
-- Name: index_source; Type: INDEX; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_source ON source.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61044 (class 2618 OID 149032)
|
||||
-- Name: table_for_rule rule1; Type: RULE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule1 AS
|
||||
ON UPDATE TO source.table_for_rule DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61070 (class 0 OID 0)
|
||||
-- Dependencies: 61044
|
||||
-- Name: RULE rule1 ON table_for_rule; Type: COMMENT; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON RULE rule1 ON source.table_for_rule IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61045 (class 2618 OID 149033)
|
||||
-- Name: table_for_rule rule2; Type: RULE; Schema: source; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule2 AS
|
||||
ON INSERT TO source.table_for_rule DO NOTHING;
|
||||
|
337
web/pgadmin/tools/schema_diff/tests/pg/9.2_plus/target.sql
Normal file
337
web/pgadmin/tools/schema_diff/tests/pg/9.2_plus/target.sql
Normal file
@@ -0,0 +1,337 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.7
|
||||
-- Dumped by pg_dump version 12beta2
|
||||
|
||||
-- Started on 2019-11-01 12:55:22 IST
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
|
||||
--
|
||||
-- TOC entry 18 (class 2615 OID 139771)
|
||||
-- Name: target; Type: SCHEMA; Schema: -; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SCHEMA target;
|
||||
|
||||
|
||||
ALTER SCHEMA target OWNER TO postgres;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA target;
|
||||
|
||||
--
|
||||
-- TOC entry 12250 (class 1259 OID 139938)
|
||||
-- Name: MView; Type: MATERIALIZED VIEW; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE MATERIALIZED VIEW target."MView" AS
|
||||
SELECT 'tekst'::text AS text
|
||||
WITH NO DATA;
|
||||
|
||||
|
||||
ALTER TABLE target."MView" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12259 (class 1259 OID 148971)
|
||||
-- Name: table_for_column; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_column (
|
||||
col1 bigint,
|
||||
col2 bigint,
|
||||
col4 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_column OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12268 (class 1259 OID 149089)
|
||||
-- Name: table_for_constraints; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_constraints (
|
||||
col1 integer NOT NULL,
|
||||
col2 text,
|
||||
CONSTRAINT check_con CHECK ((col1 > 30))
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_constraints OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 61066 (class 0 OID 0)
|
||||
-- Dependencies: 12268
|
||||
-- Name: TABLE table_for_constraints; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON TABLE target.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61067 (class 0 OID 0)
|
||||
-- Dependencies: 12268
|
||||
-- Name: CONSTRAINT check_con ON table_for_constraints; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT check_con ON target.table_for_constraints IS 'coment';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12257 (class 1259 OID 148960)
|
||||
-- Name: table_for_del; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_del (
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_del OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12271 (class 1259 OID 149172)
|
||||
-- Name: table_for_foreign_key; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_foreign_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 "char",
|
||||
col3 bigint
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_foreign_key OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12263 (class 1259 OID 149013)
|
||||
-- Name: table_for_identical; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_identical (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_identical OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12261 (class 1259 OID 148986)
|
||||
-- Name: table_for_index; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_index (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_index OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12270 (class 1259 OID 149144)
|
||||
-- Name: table_for_primary_key; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_primary_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_primary_key OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12265 (class 1259 OID 149034)
|
||||
-- Name: table_for_rule; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_rule (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_rule OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- TOC entry 12267 (class 1259 OID 149066)
|
||||
-- Name: table_for_trigger; Type: TABLE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_trigger (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_trigger OWNER TO postgres;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56906 (class 2606 OID 149097)
|
||||
-- Name: table_for_constraints Exclusion; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_constraints
|
||||
ADD CONSTRAINT "Exclusion" EXCLUDE USING gist (col2 WITH <>) WITH (fillfactor='15') WHERE ((col1 > 1)) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61068 (class 0 OID 0)
|
||||
-- Dependencies: 56906
|
||||
-- Name: CONSTRAINT "Exclusion" ON table_for_constraints; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "Exclusion" ON target.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56910 (class 2606 OID 149176)
|
||||
-- Name: table_for_foreign_key table_for_foreign_key_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_foreign_key
|
||||
ADD CONSTRAINT table_for_foreign_key_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56897 (class 2606 OID 148993)
|
||||
-- Name: table_for_index table_for_index_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_index
|
||||
ADD CONSTRAINT table_for_index_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56908 (class 2606 OID 149151)
|
||||
-- Name: table_for_primary_key table_for_primary_key_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_primary_key
|
||||
ADD CONSTRAINT table_for_primary_key_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56902 (class 2606 OID 149041)
|
||||
-- Name: table_for_rule table_for_rule_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_rule
|
||||
ADD CONSTRAINT table_for_rule_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56900 (class 2606 OID 149020)
|
||||
-- Name: table_for_identical table_for_table_for_identical_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_identical
|
||||
ADD CONSTRAINT table_for_table_for_identical_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56904 (class 2606 OID 149073)
|
||||
-- Name: table_for_trigger table_for_trigger_pkey; Type: CONSTRAINT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_trigger
|
||||
ADD CONSTRAINT table_for_trigger_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56893 (class 1259 OID 148994)
|
||||
-- Name: index1; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index1 ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56894 (class 1259 OID 148995)
|
||||
-- Name: index2; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index2 ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56898 (class 1259 OID 149021)
|
||||
-- Name: index_identical; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_identical ON target.table_for_identical USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56895 (class 1259 OID 149212)
|
||||
-- Name: index_same; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX index_same ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56892 (class 1259 OID 139945)
|
||||
-- Name: mview_index; Type: INDEX; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE INDEX mview_index ON target."MView" USING btree (text text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61045 (class 2618 OID 149042)
|
||||
-- Name: table_for_rule rule1; Type: RULE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule1 AS
|
||||
ON UPDATE TO target.table_for_rule DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61069 (class 0 OID 0)
|
||||
-- Dependencies: 61045
|
||||
-- Name: RULE rule1 ON table_for_rule; Type: COMMENT; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
COMMENT ON RULE rule1 ON target.table_for_rule IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61046 (class 2618 OID 149043)
|
||||
-- Name: table_for_rule rule2; Type: RULE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule2 AS
|
||||
ON UPDATE TO target.table_for_rule DO NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61047 (class 2618 OID 149044)
|
||||
-- Name: table_for_rule rule3; Type: RULE; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE RULE rule3 AS
|
||||
ON INSERT TO target.table_for_rule DO NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61050 (class 0 OID 139938)
|
||||
-- Dependencies: 12250 61062
|
||||
-- Name: MView; Type: MATERIALIZED VIEW DATA; Schema: target; Owner: postgres
|
||||
--
|
||||
|
||||
REFRESH MATERIALIZED VIEW target."MView";
|
376
web/pgadmin/tools/schema_diff/tests/ppas/10_plus/source.sql
Normal file
376
web/pgadmin/tools/schema_diff/tests/ppas/10_plus/source.sql
Normal file
@@ -0,0 +1,376 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.7
|
||||
-- Dumped by pg_dump version 12beta2
|
||||
|
||||
-- Started on 2019-11-01 12:54:15 IST
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- TOC entry 17 (class 2615 OID 139770)
|
||||
-- Name: source; Type: SCHEMA; Schema: -; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE SCHEMA source;
|
||||
|
||||
|
||||
ALTER SCHEMA source OWNER TO enterprisedb;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA source;
|
||||
|
||||
--
|
||||
-- TOC entry 12272 (class 1259 OID 149205)
|
||||
-- Name: table_for_partition; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_partition (
|
||||
col1 bigint NOT NULL
|
||||
)
|
||||
PARTITION BY RANGE (col1);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_partition OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12273 (class 1259 OID 149208)
|
||||
-- Name: part1; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.part1 (
|
||||
col1 bigint NOT NULL
|
||||
);
|
||||
ALTER TABLE ONLY source.table_for_partition ATTACH PARTITION source.part1 FOR VALUES FROM ('1') TO ('23');
|
||||
|
||||
|
||||
ALTER TABLE source.part1 OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12274 (class 1259 OID 149213)
|
||||
-- Name: table_for_partition_1; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_partition_1 (
|
||||
col1 bigint
|
||||
)
|
||||
PARTITION BY RANGE (col1);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_partition_1 OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12275 (class 1259 OID 149216)
|
||||
-- Name: part3; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.part3 (
|
||||
col1 bigint
|
||||
);
|
||||
ALTER TABLE ONLY source.table_for_partition_1 ATTACH PARTITION source.part3 FOR VALUES FROM ('1') TO ('10');
|
||||
|
||||
|
||||
ALTER TABLE source.part3 OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12276 (class 1259 OID 149219)
|
||||
-- Name: part4; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.part4 (
|
||||
col1 bigint
|
||||
);
|
||||
ALTER TABLE ONLY source.table_for_partition_1 ATTACH PARTITION source.part4 FOR VALUES FROM ('11') TO ('20');
|
||||
|
||||
|
||||
ALTER TABLE source.part4 OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12258 (class 1259 OID 148963)
|
||||
-- Name: table_for_column; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_column (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text,
|
||||
col3 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_column OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12256 (class 1259 OID 148895)
|
||||
-- Name: table_for_constraints; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_constraints (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_constraints OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 61066 (class 0 OID 0)
|
||||
-- Dependencies: 12256
|
||||
-- Name: TABLE table_for_constraints; Type: COMMENT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON TABLE source.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12262 (class 1259 OID 149004)
|
||||
-- Name: table_for_identical; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_identical (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_identical OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12260 (class 1259 OID 148977)
|
||||
-- Name: table_for_index; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_index (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_index OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12269 (class 1259 OID 149128)
|
||||
-- Name: table_for_primary_key; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_primary_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_primary_key OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12264 (class 1259 OID 149024)
|
||||
-- Name: table_for_rule; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_rule (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_rule OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12266 (class 1259 OID 149048)
|
||||
-- Name: table_for_trigger; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_trigger (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_trigger OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 56893 (class 2606 OID 148904)
|
||||
-- Name: table_for_constraints Exclusion; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT "Exclusion" EXCLUDE USING gist (col2 WITH <>) WITH (fillfactor='12') WHERE ((col1 > 1)) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61067 (class 0 OID 0)
|
||||
-- Dependencies: 56893
|
||||
-- Name: CONSTRAINT "Exclusion" ON table_for_constraints; Type: COMMENT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "Exclusion" ON source.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56891 (class 2606 OID 148911)
|
||||
-- Name: table_for_constraints check_con; Type: CHECK CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE source.table_for_constraints
|
||||
ADD CONSTRAINT check_con CHECK ((col1 > 10)) NOT VALID;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61068 (class 0 OID 0)
|
||||
-- Dependencies: 56891
|
||||
-- Name: CONSTRAINT check_con ON table_for_constraints; Type: COMMENT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT check_con ON source.table_for_constraints IS 'coment';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56899 (class 2606 OID 148970)
|
||||
-- Name: table_for_column table_for_column_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_column
|
||||
ADD CONSTRAINT table_for_column_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56895 (class 2606 OID 148902)
|
||||
-- Name: table_for_constraints table_for_constraints_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT table_for_constraints_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56904 (class 2606 OID 148984)
|
||||
-- Name: table_for_index table_for_index_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_index
|
||||
ADD CONSTRAINT table_for_index_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56913 (class 2606 OID 149135)
|
||||
-- Name: table_for_primary_key table_for_primary_key_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_primary_key
|
||||
ADD CONSTRAINT table_for_primary_key_pkey PRIMARY KEY (col1, col2);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56909 (class 2606 OID 149031)
|
||||
-- Name: table_for_rule table_for_rule_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_rule
|
||||
ADD CONSTRAINT table_for_rule_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56907 (class 2606 OID 149011)
|
||||
-- Name: table_for_identical table_for_table_for_identical_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_identical
|
||||
ADD CONSTRAINT table_for_table_for_identical_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56911 (class 2606 OID 149055)
|
||||
-- Name: table_for_trigger table_for_trigger_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_trigger
|
||||
ADD CONSTRAINT table_for_trigger_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56897 (class 2606 OID 148913)
|
||||
-- Name: table_for_constraints unique; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT "unique" UNIQUE (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61069 (class 0 OID 0)
|
||||
-- Dependencies: 56897
|
||||
-- Name: CONSTRAINT "unique" ON table_for_constraints; Type: COMMENT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "unique" ON source.table_for_constraints IS 'cmnt';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56900 (class 1259 OID 149023)
|
||||
-- Name: index1; Type: INDEX; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index1 ON source.table_for_index USING btree (col2 varchar_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56905 (class 1259 OID 149012)
|
||||
-- Name: index_identical; Type: INDEX; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index_identical ON source.table_for_identical USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56901 (class 1259 OID 149211)
|
||||
-- Name: index_same; Type: INDEX; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index_same ON source.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56902 (class 1259 OID 149022)
|
||||
-- Name: index_source; Type: INDEX; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index_source ON source.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61044 (class 2618 OID 149032)
|
||||
-- Name: table_for_rule rule1; Type: RULE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE RULE rule1 AS
|
||||
ON UPDATE TO source.table_for_rule DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61070 (class 0 OID 0)
|
||||
-- Dependencies: 61044
|
||||
-- Name: RULE rule1 ON table_for_rule; Type: COMMENT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON RULE rule1 ON source.table_for_rule IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61045 (class 2618 OID 149033)
|
||||
-- Name: table_for_rule rule2; Type: RULE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE RULE rule2 AS
|
||||
ON INSERT TO source.table_for_rule DO NOTHING;
|
364
web/pgadmin/tools/schema_diff/tests/ppas/10_plus/target.sql
Normal file
364
web/pgadmin/tools/schema_diff/tests/ppas/10_plus/target.sql
Normal file
@@ -0,0 +1,364 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.7
|
||||
-- Dumped by pg_dump version 12beta2
|
||||
|
||||
-- Started on 2019-11-01 12:55:22 IST
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- TOC entry 18 (class 2615 OID 139771)
|
||||
-- Name: target; Type: SCHEMA; Schema: -; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE SCHEMA target;
|
||||
|
||||
ALTER SCHEMA target OWNER TO enterprisedb;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA target;
|
||||
|
||||
--
|
||||
-- TOC entry 12250 (class 1259 OID 139938)
|
||||
-- Name: MView; Type: MATERIALIZED VIEW; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE MATERIALIZED VIEW target."MView" AS
|
||||
SELECT 'tekst'::text AS text
|
||||
WITH NO DATA;
|
||||
|
||||
|
||||
ALTER TABLE target."MView" OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12277 (class 1259 OID 149234)
|
||||
-- Name: table_for_partition_1; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_partition_1 (
|
||||
col1 bigint
|
||||
)
|
||||
PARTITION BY RANGE (col1);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_partition_1 OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12278 (class 1259 OID 149237)
|
||||
-- Name: part3; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.part3 (
|
||||
col1 bigint
|
||||
);
|
||||
ALTER TABLE ONLY target.table_for_partition_1 ATTACH PARTITION target.part3 FOR VALUES FROM ('13') TO ('56');
|
||||
|
||||
|
||||
ALTER TABLE target.part3 OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12259 (class 1259 OID 148971)
|
||||
-- Name: table_for_column; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_column (
|
||||
col1 bigint,
|
||||
col2 bigint,
|
||||
col4 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_column OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12268 (class 1259 OID 149089)
|
||||
-- Name: table_for_constraints; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_constraints (
|
||||
col1 integer NOT NULL,
|
||||
col2 text,
|
||||
CONSTRAINT check_con CHECK ((col1 > 30))
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_constraints OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 61066 (class 0 OID 0)
|
||||
-- Dependencies: 12268
|
||||
-- Name: TABLE table_for_constraints; Type: COMMENT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON TABLE target.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61067 (class 0 OID 0)
|
||||
-- Dependencies: 12268
|
||||
-- Name: CONSTRAINT check_con ON table_for_constraints; Type: COMMENT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT check_con ON target.table_for_constraints IS 'coment';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12257 (class 1259 OID 148960)
|
||||
-- Name: table_for_del; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_del (
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_del OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12271 (class 1259 OID 149172)
|
||||
-- Name: table_for_foreign_key; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_foreign_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 "char",
|
||||
col3 bigint
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_foreign_key OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12263 (class 1259 OID 149013)
|
||||
-- Name: table_for_identical; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_identical (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_identical OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12261 (class 1259 OID 148986)
|
||||
-- Name: table_for_index; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_index (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_index OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12270 (class 1259 OID 149144)
|
||||
-- Name: table_for_primary_key; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_primary_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_primary_key OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12265 (class 1259 OID 149034)
|
||||
-- Name: table_for_rule; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_rule (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_rule OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12267 (class 1259 OID 149066)
|
||||
-- Name: table_for_trigger; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_trigger (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_trigger OWNER TO enterprisedb;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56906 (class 2606 OID 149097)
|
||||
-- Name: table_for_constraints Exclusion; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_constraints
|
||||
ADD CONSTRAINT "Exclusion" EXCLUDE USING gist (col2 WITH <>) WITH (fillfactor='15') WHERE ((col1 > 1)) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61068 (class 0 OID 0)
|
||||
-- Dependencies: 56906
|
||||
-- Name: CONSTRAINT "Exclusion" ON table_for_constraints; Type: COMMENT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "Exclusion" ON target.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56910 (class 2606 OID 149176)
|
||||
-- Name: table_for_foreign_key table_for_foreign_key_pkey; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_foreign_key
|
||||
ADD CONSTRAINT table_for_foreign_key_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56897 (class 2606 OID 148993)
|
||||
-- Name: table_for_index table_for_index_pkey; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_index
|
||||
ADD CONSTRAINT table_for_index_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56908 (class 2606 OID 149151)
|
||||
-- Name: table_for_primary_key table_for_primary_key_pkey; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_primary_key
|
||||
ADD CONSTRAINT table_for_primary_key_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56902 (class 2606 OID 149041)
|
||||
-- Name: table_for_rule table_for_rule_pkey; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_rule
|
||||
ADD CONSTRAINT table_for_rule_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56900 (class 2606 OID 149020)
|
||||
-- Name: table_for_identical table_for_table_for_identical_pkey; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_identical
|
||||
ADD CONSTRAINT table_for_table_for_identical_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56904 (class 2606 OID 149073)
|
||||
-- Name: table_for_trigger table_for_trigger_pkey; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_trigger
|
||||
ADD CONSTRAINT table_for_trigger_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56893 (class 1259 OID 148994)
|
||||
-- Name: index1; Type: INDEX; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index1 ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56894 (class 1259 OID 148995)
|
||||
-- Name: index2; Type: INDEX; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index2 ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56898 (class 1259 OID 149021)
|
||||
-- Name: index_identical; Type: INDEX; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index_identical ON target.table_for_identical USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56895 (class 1259 OID 149212)
|
||||
-- Name: index_same; Type: INDEX; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index_same ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56892 (class 1259 OID 139945)
|
||||
-- Name: mview_index; Type: INDEX; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX mview_index ON target."MView" USING btree (text text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61045 (class 2618 OID 149042)
|
||||
-- Name: table_for_rule rule1; Type: RULE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE RULE rule1 AS
|
||||
ON UPDATE TO target.table_for_rule DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61069 (class 0 OID 0)
|
||||
-- Dependencies: 61045
|
||||
-- Name: RULE rule1 ON table_for_rule; Type: COMMENT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON RULE rule1 ON target.table_for_rule IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61046 (class 2618 OID 149043)
|
||||
-- Name: table_for_rule rule2; Type: RULE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE RULE rule2 AS
|
||||
ON UPDATE TO target.table_for_rule DO NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61047 (class 2618 OID 149044)
|
||||
-- Name: table_for_rule rule3; Type: RULE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE RULE rule3 AS
|
||||
ON INSERT TO target.table_for_rule DO NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61050 (class 0 OID 139938)
|
||||
-- Dependencies: 12250 61062
|
||||
-- Name: MView; Type: MATERIALIZED VIEW DATA; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
REFRESH MATERIALIZED VIEW target."MView";
|
311
web/pgadmin/tools/schema_diff/tests/ppas/9.2_plus/source.sql
Normal file
311
web/pgadmin/tools/schema_diff/tests/ppas/9.2_plus/source.sql
Normal file
@@ -0,0 +1,311 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.7
|
||||
-- Dumped by pg_dump version 12beta2
|
||||
|
||||
-- Started on 2019-11-01 12:54:15 IST
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
|
||||
--
|
||||
-- TOC entry 17 (class 2615 OID 139770)
|
||||
-- Name: source; Type: SCHEMA; Schema: -; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE SCHEMA source;
|
||||
|
||||
|
||||
ALTER SCHEMA source OWNER TO enterprisedb;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA source;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12258 (class 1259 OID 148963)
|
||||
-- Name: table_for_column; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_column (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text,
|
||||
col3 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_column OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12256 (class 1259 OID 148895)
|
||||
-- Name: table_for_constraints; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_constraints (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_constraints OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 61066 (class 0 OID 0)
|
||||
-- Dependencies: 12256
|
||||
-- Name: TABLE table_for_constraints; Type: COMMENT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON TABLE source.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12262 (class 1259 OID 149004)
|
||||
-- Name: table_for_identical; Type: TABLE; Schema: source; Owner: enterprisedb;
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_identical (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_identical OWNER TO enterprisedb;;
|
||||
|
||||
--
|
||||
-- TOC entry 12260 (class 1259 OID 148977)
|
||||
-- Name: table_for_index; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_index (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_index OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12269 (class 1259 OID 149128)
|
||||
-- Name: table_for_primary_key; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_primary_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_primary_key OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12264 (class 1259 OID 149024)
|
||||
-- Name: table_for_rule; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_rule (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_rule OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12266 (class 1259 OID 149048)
|
||||
-- Name: table_for_trigger; Type: TABLE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE source.table_for_trigger (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE source.table_for_trigger OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 56893 (class 2606 OID 148904)
|
||||
-- Name: table_for_constraints Exclusion; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT "Exclusion" EXCLUDE USING gist (col2 WITH <>) WITH (fillfactor='12') WHERE ((col1 > 1)) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61067 (class 0 OID 0)
|
||||
-- Dependencies: 56893
|
||||
-- Name: CONSTRAINT "Exclusion" ON table_for_constraints; Type: COMMENT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "Exclusion" ON source.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56891 (class 2606 OID 148911)
|
||||
-- Name: table_for_constraints check_con; Type: CHECK CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE source.table_for_constraints
|
||||
ADD CONSTRAINT check_con CHECK ((col1 > 10)) NOT VALID;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61068 (class 0 OID 0)
|
||||
-- Dependencies: 56891
|
||||
-- Name: CONSTRAINT check_con ON table_for_constraints; Type: COMMENT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT check_con ON source.table_for_constraints IS 'coment';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56899 (class 2606 OID 148970)
|
||||
-- Name: table_for_column table_for_column_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_column
|
||||
ADD CONSTRAINT table_for_column_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56895 (class 2606 OID 148902)
|
||||
-- Name: table_for_constraints table_for_constraints_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT table_for_constraints_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56904 (class 2606 OID 148984)
|
||||
-- Name: table_for_index table_for_index_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_index
|
||||
ADD CONSTRAINT table_for_index_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56913 (class 2606 OID 149135)
|
||||
-- Name: table_for_primary_key table_for_primary_key_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_primary_key
|
||||
ADD CONSTRAINT table_for_primary_key_pkey PRIMARY KEY (col1, col2);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56909 (class 2606 OID 149031)
|
||||
-- Name: table_for_rule table_for_rule_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_rule
|
||||
ADD CONSTRAINT table_for_rule_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56907 (class 2606 OID 149011)
|
||||
-- Name: table_for_identical table_for_table_for_identical_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb;
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_identical
|
||||
ADD CONSTRAINT table_for_table_for_identical_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56911 (class 2606 OID 149055)
|
||||
-- Name: table_for_trigger table_for_trigger_pkey; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_trigger
|
||||
ADD CONSTRAINT table_for_trigger_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56897 (class 2606 OID 148913)
|
||||
-- Name: table_for_constraints unique; Type: CONSTRAINT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY source.table_for_constraints
|
||||
ADD CONSTRAINT "unique" UNIQUE (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61069 (class 0 OID 0)
|
||||
-- Dependencies: 56897
|
||||
-- Name: CONSTRAINT "unique" ON table_for_constraints; Type: COMMENT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "unique" ON source.table_for_constraints IS 'cmnt';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56900 (class 1259 OID 149023)
|
||||
-- Name: index1; Type: INDEX; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index1 ON source.table_for_index USING btree (col2 varchar_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56905 (class 1259 OID 149012)
|
||||
-- Name: index_identical; Type: INDEX; Schema: source; Owner: enterprisedb;
|
||||
--
|
||||
|
||||
CREATE INDEX index_identical ON source.table_for_identical USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56901 (class 1259 OID 149211)
|
||||
-- Name: index_same; Type: INDEX; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index_same ON source.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56902 (class 1259 OID 149022)
|
||||
-- Name: index_source; Type: INDEX; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index_source ON source.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61044 (class 2618 OID 149032)
|
||||
-- Name: table_for_rule rule1; Type: RULE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE RULE rule1 AS
|
||||
ON UPDATE TO source.table_for_rule DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61070 (class 0 OID 0)
|
||||
-- Dependencies: 61044
|
||||
-- Name: RULE rule1 ON table_for_rule; Type: COMMENT; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON RULE rule1 ON source.table_for_rule IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61045 (class 2618 OID 149033)
|
||||
-- Name: table_for_rule rule2; Type: RULE; Schema: source; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE RULE rule2 AS
|
||||
ON INSERT TO source.table_for_rule DO NOTHING;
|
||||
|
337
web/pgadmin/tools/schema_diff/tests/ppas/9.2_plus/target.sql
Normal file
337
web/pgadmin/tools/schema_diff/tests/ppas/9.2_plus/target.sql
Normal file
@@ -0,0 +1,337 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.7
|
||||
-- Dumped by pg_dump version 12beta2
|
||||
|
||||
-- Started on 2019-11-01 12:55:22 IST
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
|
||||
--
|
||||
-- TOC entry 18 (class 2615 OID 139771)
|
||||
-- Name: target; Type: SCHEMA; Schema: -; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE SCHEMA target;
|
||||
|
||||
|
||||
ALTER SCHEMA target OWNER TO enterprisedb;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA target;
|
||||
|
||||
--
|
||||
-- TOC entry 12250 (class 1259 OID 139938)
|
||||
-- Name: MView; Type: MATERIALIZED VIEW; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE MATERIALIZED VIEW target."MView" AS
|
||||
SELECT 'tekst'::text AS text
|
||||
WITH NO DATA;
|
||||
|
||||
|
||||
ALTER TABLE target."MView" OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12259 (class 1259 OID 148971)
|
||||
-- Name: table_for_column; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_column (
|
||||
col1 bigint,
|
||||
col2 bigint,
|
||||
col4 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_column OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12268 (class 1259 OID 149089)
|
||||
-- Name: table_for_constraints; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_constraints (
|
||||
col1 integer NOT NULL,
|
||||
col2 text,
|
||||
CONSTRAINT check_con CHECK ((col1 > 30))
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_constraints OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 61066 (class 0 OID 0)
|
||||
-- Dependencies: 12268
|
||||
-- Name: TABLE table_for_constraints; Type: COMMENT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON TABLE target.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61067 (class 0 OID 0)
|
||||
-- Dependencies: 12268
|
||||
-- Name: CONSTRAINT check_con ON table_for_constraints; Type: COMMENT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT check_con ON target.table_for_constraints IS 'coment';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12257 (class 1259 OID 148960)
|
||||
-- Name: table_for_del; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_del (
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_del OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12271 (class 1259 OID 149172)
|
||||
-- Name: table_for_foreign_key; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_foreign_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 "char",
|
||||
col3 bigint
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_foreign_key OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12263 (class 1259 OID 149013)
|
||||
-- Name: table_for_identical; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_identical (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_identical OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12261 (class 1259 OID 148986)
|
||||
-- Name: table_for_index; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_index (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_index OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12270 (class 1259 OID 149144)
|
||||
-- Name: table_for_primary_key; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_primary_key (
|
||||
col1 integer NOT NULL,
|
||||
col2 text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_primary_key OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12265 (class 1259 OID 149034)
|
||||
-- Name: table_for_rule; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_rule (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_rule OWNER TO enterprisedb;
|
||||
|
||||
--
|
||||
-- TOC entry 12267 (class 1259 OID 149066)
|
||||
-- Name: table_for_trigger; Type: TABLE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE TABLE target.table_for_trigger (
|
||||
col1 bigint NOT NULL,
|
||||
col2 text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE target.table_for_trigger OWNER TO enterprisedb;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56906 (class 2606 OID 149097)
|
||||
-- Name: table_for_constraints Exclusion; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_constraints
|
||||
ADD CONSTRAINT "Exclusion" EXCLUDE USING gist (col2 WITH <>) WITH (fillfactor='15') WHERE ((col1 > 1)) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61068 (class 0 OID 0)
|
||||
-- Dependencies: 56906
|
||||
-- Name: CONSTRAINT "Exclusion" ON table_for_constraints; Type: COMMENT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON CONSTRAINT "Exclusion" ON target.table_for_constraints IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56910 (class 2606 OID 149176)
|
||||
-- Name: table_for_foreign_key table_for_foreign_key_pkey; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_foreign_key
|
||||
ADD CONSTRAINT table_for_foreign_key_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56897 (class 2606 OID 148993)
|
||||
-- Name: table_for_index table_for_index_pkey; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_index
|
||||
ADD CONSTRAINT table_for_index_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56908 (class 2606 OID 149151)
|
||||
-- Name: table_for_primary_key table_for_primary_key_pkey; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_primary_key
|
||||
ADD CONSTRAINT table_for_primary_key_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56902 (class 2606 OID 149041)
|
||||
-- Name: table_for_rule table_for_rule_pkey; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_rule
|
||||
ADD CONSTRAINT table_for_rule_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56900 (class 2606 OID 149020)
|
||||
-- Name: table_for_identical table_for_table_for_identical_pkey; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_identical
|
||||
ADD CONSTRAINT table_for_table_for_identical_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56904 (class 2606 OID 149073)
|
||||
-- Name: table_for_trigger table_for_trigger_pkey; Type: CONSTRAINT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY target.table_for_trigger
|
||||
ADD CONSTRAINT table_for_trigger_pkey PRIMARY KEY (col1);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56893 (class 1259 OID 148994)
|
||||
-- Name: index1; Type: INDEX; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index1 ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56894 (class 1259 OID 148995)
|
||||
-- Name: index2; Type: INDEX; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index2 ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56898 (class 1259 OID 149021)
|
||||
-- Name: index_identical; Type: INDEX; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index_identical ON target.table_for_identical USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56895 (class 1259 OID 149212)
|
||||
-- Name: index_same; Type: INDEX; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX index_same ON target.table_for_index USING btree (col2 text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 56892 (class 1259 OID 139945)
|
||||
-- Name: mview_index; Type: INDEX; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE INDEX mview_index ON target."MView" USING btree (text text_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61045 (class 2618 OID 149042)
|
||||
-- Name: table_for_rule rule1; Type: RULE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE RULE rule1 AS
|
||||
ON UPDATE TO target.table_for_rule DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61069 (class 0 OID 0)
|
||||
-- Dependencies: 61045
|
||||
-- Name: RULE rule1 ON table_for_rule; Type: COMMENT; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
COMMENT ON RULE rule1 ON target.table_for_rule IS 'comments';
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61046 (class 2618 OID 149043)
|
||||
-- Name: table_for_rule rule2; Type: RULE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE RULE rule2 AS
|
||||
ON UPDATE TO target.table_for_rule DO NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61047 (class 2618 OID 149044)
|
||||
-- Name: table_for_rule rule3; Type: RULE; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
CREATE RULE rule3 AS
|
||||
ON INSERT TO target.table_for_rule DO NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 61050 (class 0 OID 139938)
|
||||
-- Dependencies: 12250 61062
|
||||
-- Name: MView; Type: MATERIALIZED VIEW DATA; Schema: target; Owner: enterprisedb
|
||||
--
|
||||
|
||||
REFRESH MATERIALIZED VIEW target."MView";
|
204
web/pgadmin/tools/schema_diff/tests/test_schema_diff_comp.py
Normal file
204
web/pgadmin/tools/schema_diff/tests/test_schema_diff_comp.py
Normal file
@@ -0,0 +1,204 @@
|
||||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
import uuid
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
|
||||
from pgadmin.utils import server_utils as server_utils
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from regression import parent_node_dict
|
||||
from regression.python_test_utils import test_utils as utils
|
||||
from .utils import create_table, create_schema, restore_schema
|
||||
from pgadmin.browser.server_groups.servers.databases.tests import utils as \
|
||||
database_utils
|
||||
from pgadmin.utils.versioned_template_loader import \
|
||||
get_version_mapping_directories
|
||||
|
||||
|
||||
class SchemaDiffTestCase(BaseTestGenerator):
|
||||
""" This class will test the schema diff. """
|
||||
scenarios = [
|
||||
# Fetching default URL for database node.
|
||||
('Schema diff comparison', dict(
|
||||
url='schema_diff/compare/{0}/{1}/{2}/{3}/{4}/{5}/{6}'))
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
self.src_database = "db_schema_diff_src_%s" % str(uuid.uuid4())[1:8]
|
||||
self.tar_database = "db_schema_diff_tar_%s" % str(uuid.uuid4())[1:8]
|
||||
|
||||
self.src_db_id = utils.create_database(self.server, self.src_database)
|
||||
self.tar_db_id = utils.create_database(self.server, self.tar_database)
|
||||
|
||||
self.server = parent_node_dict["server"][-1]["server"]
|
||||
self.server_id = parent_node_dict["server"][-1]["server_id"]
|
||||
self.nodes = ['table', 'function', 'procedure', 'view', 'mview']
|
||||
self.restore_backup()
|
||||
|
||||
def restore_backup(self):
|
||||
self.sql_folder = self.get_sql_folder()
|
||||
|
||||
if self.sql_folder is None:
|
||||
raise FileNotFoundError('Schema diff folder does not exists')
|
||||
|
||||
src_sql_path = os.path.join(self.sql_folder, 'source.sql')
|
||||
tar_sql_path = os.path.join(self.sql_folder, 'target.sql')
|
||||
|
||||
if not os.path.exists(src_sql_path):
|
||||
raise FileNotFoundError(
|
||||
'{} file does not exists'.format(src_sql_path))
|
||||
|
||||
if not os.path.exists(tar_sql_path):
|
||||
raise FileNotFoundError(
|
||||
'{} file does not exists'.format(tar_sql_path))
|
||||
|
||||
self.src_schema_id = restore_schema(self.server, self.src_database,
|
||||
'source', src_sql_path)
|
||||
self.tar_schema_id = restore_schema(self.server, self.tar_database,
|
||||
'target', tar_sql_path)
|
||||
|
||||
def get_sql_folder(self):
|
||||
"""
|
||||
This function will get the appropriate test folder based on
|
||||
server version and their existence.
|
||||
|
||||
:param module_path: Path of the module to be tested.
|
||||
:return:
|
||||
"""
|
||||
# Join the application path, module path and tests folder
|
||||
tests_folder_path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# A folder name matching the Server Type (pg, ppas) takes priority so
|
||||
# check whether that exists or not. If so, than check the version
|
||||
# folder in it, else look directly in the 'tests' folder.
|
||||
absolute_path = os.path.join(tests_folder_path, self.server['type'])
|
||||
if not os.path.exists(absolute_path):
|
||||
absolute_path = tests_folder_path
|
||||
|
||||
# Iterate the version mapping directories.
|
||||
for version_mapping in get_version_mapping_directories(
|
||||
self.server['type']):
|
||||
if version_mapping['number'] > \
|
||||
self.server_information['server_version']:
|
||||
continue
|
||||
|
||||
complete_path = os.path.join(absolute_path,
|
||||
version_mapping['name'])
|
||||
|
||||
if os.path.exists(complete_path):
|
||||
return complete_path
|
||||
|
||||
return None
|
||||
|
||||
def compare(self):
|
||||
comp_url = self.url.format(self.trans_id, self.server_id,
|
||||
self.src_db_id,
|
||||
self.src_schema_id,
|
||||
self.server_id,
|
||||
self.tar_db_id,
|
||||
self.tar_schema_id
|
||||
)
|
||||
|
||||
response = self.tester.get(comp_url)
|
||||
|
||||
self.assertEquals(response.status_code, 200)
|
||||
return json.loads(response.data.decode('utf-8'))
|
||||
|
||||
def runTest(self):
|
||||
""" This function will test the schema diff."""
|
||||
|
||||
response = self.tester.get("schema_diff/initialize")
|
||||
self.assertEquals(response.status_code, 200)
|
||||
response_data = json.loads(response.data.decode('utf-8'))
|
||||
self.trans_id = response_data['data']['schemaDiffTransId']
|
||||
|
||||
url = 'schema_diff/server/connect/{}'.format(self.server_id)
|
||||
data = {'password': self.server['db_password']}
|
||||
response = self.tester.post(url,
|
||||
data=json.dumps(data),
|
||||
content_type='html/json'
|
||||
)
|
||||
response = self.tester.post(
|
||||
'schema_diff/database/connect/{0}/{1}'.format(
|
||||
self.server_id,
|
||||
self.src_db_id))
|
||||
response = self.tester.post(
|
||||
'schema_diff/database/connect/{0}/{1}'.format(
|
||||
self.server_id,
|
||||
self.tar_db_id))
|
||||
|
||||
response_data = self.compare()
|
||||
|
||||
diff_file = os.path.join(self.sql_folder, 'diff_{0}.sql'.format(
|
||||
str(random.randint(1, 99999))))
|
||||
file_obj = open(diff_file, 'a')
|
||||
|
||||
for diff in response_data['data']:
|
||||
if diff['type'] in self.nodes:
|
||||
src_obj_oid = tar_obj_oid = None
|
||||
if diff['status'] == 'Source Only' or\
|
||||
diff['status'] == 'Target Only':
|
||||
src_obj_oid = tar_obj_oid = diff['oid']
|
||||
elif diff['status'] == 'Different':
|
||||
src_obj_oid = diff['source_oid']
|
||||
tar_obj_oid = diff['target_oid']
|
||||
|
||||
if src_obj_oid is not None:
|
||||
url = 'schema_diff/ddl_compare/{0}/{1}/{2}/{3}/{4}/{5}/' \
|
||||
'{6}/{7}/{8}/{9}/{10}/'.format(self.trans_id,
|
||||
self.server_id,
|
||||
self.src_db_id,
|
||||
self.src_schema_id,
|
||||
self.server_id,
|
||||
self.tar_db_id,
|
||||
self.tar_schema_id,
|
||||
src_obj_oid,
|
||||
tar_obj_oid,
|
||||
diff['type'],
|
||||
diff['status']
|
||||
)
|
||||
|
||||
response = self.tester.get(url)
|
||||
|
||||
self.assertEquals(response.status_code, 200)
|
||||
response_data = json.loads(response.data.decode('utf-8'))
|
||||
file_obj.write(response_data['diff_ddl'])
|
||||
|
||||
file_obj.close()
|
||||
try:
|
||||
restore_schema(self.server, self.tar_database, 'target',
|
||||
diff_file)
|
||||
|
||||
os.remove(diff_file)
|
||||
|
||||
response_data = self.compare()
|
||||
for diff in response_data['data']:
|
||||
if diff['type'] in self.nodes:
|
||||
self.assertEquals(diff['status'], 'Identical')
|
||||
except Exception as e:
|
||||
os.remove(diff_file)
|
||||
|
||||
def tearDown(self):
|
||||
"""This function drop the added database"""
|
||||
connection = utils.get_db_connection(self.server['db'],
|
||||
self.server['username'],
|
||||
self.server['db_password'],
|
||||
self.server['host'],
|
||||
self.server['port'],
|
||||
self.server['sslmode'])
|
||||
utils.drop_database(connection, self.src_database)
|
||||
connection = utils.get_db_connection(self.server['db'],
|
||||
self.server['username'],
|
||||
self.server['db_password'],
|
||||
self.server['host'],
|
||||
self.server['port'],
|
||||
self.server['sslmode'])
|
||||
utils.drop_database(connection, self.tar_database)
|
103
web/pgadmin/tools/schema_diff/tests/utils.py
Normal file
103
web/pgadmin/tools/schema_diff/tests/utils.py
Normal file
@@ -0,0 +1,103 @@
|
||||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from regression.python_test_utils import test_utils as utils
|
||||
from pgadmin.browser.server_groups.servers.databases.schemas.tests import \
|
||||
utils as schema_utils
|
||||
|
||||
|
||||
def restore_schema(server, db_name, schema_name, sql_path):
|
||||
connection = utils.get_db_connection(db_name,
|
||||
server['username'],
|
||||
server['db_password'],
|
||||
server['host'],
|
||||
server['port'],
|
||||
server['sslmode']
|
||||
)
|
||||
|
||||
old_isolation_level = connection.isolation_level
|
||||
connection.set_isolation_level(0)
|
||||
pg_cursor = connection.cursor()
|
||||
|
||||
sql = ''
|
||||
with open(sql_path, 'r') as content_file:
|
||||
sql = content_file.read()
|
||||
pg_cursor.execute(sql)
|
||||
connection.set_isolation_level(old_isolation_level)
|
||||
connection.commit()
|
||||
|
||||
SQL = """SELECT
|
||||
nsp.oid
|
||||
FROM
|
||||
pg_namespace nsp
|
||||
WHERE nsp.nspname = '{0}'""".format(schema_name)
|
||||
|
||||
pg_cursor.execute(SQL)
|
||||
schema = pg_cursor.fetchone()
|
||||
schema_id = None
|
||||
if schema:
|
||||
schema_id = schema[0]
|
||||
connection.close()
|
||||
return schema_id
|
||||
|
||||
|
||||
def create_schema(server, db_name, schema_name):
|
||||
connection = utils.get_db_connection(db_name,
|
||||
server['username'],
|
||||
server['db_password'],
|
||||
server['host'],
|
||||
server['port'],
|
||||
server['sslmode']
|
||||
)
|
||||
return schema_utils.create_schema(connection, schema_name)
|
||||
|
||||
|
||||
def create_table(server, db_name, schema_id, table_name, query):
|
||||
"""
|
||||
This function creates a table under provided schema.
|
||||
:param server: server details
|
||||
:type server: dict
|
||||
:param db_name: database name
|
||||
:type db_name: str
|
||||
:param schema_id: schema oid
|
||||
:type schema_name: int
|
||||
:param table_name: table name
|
||||
:type table_name: str
|
||||
:return table_id: table id
|
||||
:rtype: int
|
||||
"""
|
||||
try:
|
||||
connection = utils.get_db_connection(db_name,
|
||||
server['username'],
|
||||
server['db_password'],
|
||||
server['host'],
|
||||
server['port'],
|
||||
server['sslmode'])
|
||||
old_isolation_level = connection.isolation_level
|
||||
connection.set_isolation_level(0)
|
||||
pg_cursor = connection.cursor()
|
||||
pg_cursor.execute(query)
|
||||
connection.set_isolation_level(old_isolation_level)
|
||||
connection.commit()
|
||||
# Get 'oid' from newly created table
|
||||
pg_cursor.execute("SELECT oid FROM pg_class WHERE relname='{0}'"
|
||||
" AND relnamespace = {1}".format(table_name,
|
||||
schema_id))
|
||||
table = pg_cursor.fetchone()
|
||||
table_id = ''
|
||||
if table:
|
||||
table_id = table[0]
|
||||
connection.close()
|
||||
return table_id
|
||||
except Exception:
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
raise
|
Reference in New Issue
Block a user