diff --git a/pgadmin/Makefile.am b/pgadmin/Makefile.am
index 3b58f58..cc93bc0 100644
--- a/pgadmin/Makefile.am
+++ b/pgadmin/Makefile.am
@@ -40,9 +40,11 @@ include $(srcdir)/pgscript/module.mk
 include $(srcdir)/schema/module.mk
 include $(srcdir)/slony/module.mk
 include $(srcdir)/gqb/module.mk
+include $(srcdir)/sv/module.mk
 include $(srcdir)/ui/module.mk
 include $(srcdir)/utils/module.mk
 
+
 if SUN_CC
   __CFLAGS=""
 else
diff --git a/pgadmin/frm/frmMain.cpp b/pgadmin/frm/frmMain.cpp
index bcc39e6..5cd238f 100644
--- a/pgadmin/frm/frmMain.cpp
+++ b/pgadmin/frm/frmMain.cpp
@@ -76,6 +76,8 @@
 #include "schema/pgServer.h"
 #include "slony/slCluster.h"
 #include "slony/slSet.h"
+#include "sv/dlgAuthServer.h"
+
 
 
 #if wxDIALOG_UNIT_COMPATIBILITY
@@ -209,6 +211,8 @@ frmMain::frmMain(const wxString& title)
     // Add the root node
     serversObj = new pgServerCollection(serverFactory.GetCollectionFactory());
     wxTreeItemId root = browser->AddRoot(_("Server Groups"), serversObj->GetIconId(), -1, serversObj);
+	wxTreeItemId idroot  = serversObj->GetId();
+
 
     // Load servers
     RetrieveServers();
@@ -289,6 +293,7 @@ void frmMain::CreateMenus()
     new separatorFactory(menuFactories);
 
     toolBar->AddSeparator();
+	
 
     new passwordFactory(menuFactories, fileMenu, 0);
     fileMenu->AppendSeparator();
@@ -350,6 +355,7 @@ void frmMain::CreateMenus()
     new separatorFactory(menuFactories);
 
     toolBar->AddSeparator();
+   
     toolsMenu->AppendSeparator();
     
     debuggingMenuFactory = new submenuFactory(menuFactories);     // placeholder where "Debugging" submenu will be inserted
@@ -414,7 +420,10 @@ void frmMain::CreateMenus()
     //--------------------------
     toolBar->AddSeparator();
 
-    actionFactory *helpFact=new contentsFactory(menuFactories, helpMenu, 0);
+	
+	new SyncVisualizerFactory(menuFactories, viewMenu, toolBar);
+
+	actionFactory *helpFact=new contentsFactory(menuFactories, helpMenu, 0);
     new hintFactory(menuFactories, helpMenu, toolBar, true);
     new faqFactory(menuFactories, helpMenu, 0);
     new bugReportFactory(menuFactories, helpMenu, 0);
@@ -427,7 +436,7 @@ void frmMain::CreateMenus()
     if (!appearanceFactory->GetHideGreenplumHelp())
         new greenplumHelpFactory(menuFactories, helpMenu, toolBar, true);
     new slonyHelpFactory(menuFactories, helpMenu, toolBar, true);
-    
+
     // Don't include this seperator on Mac, because the only option
     // under it will be moved to the application menu.
 #ifndef __WXMAC__
@@ -1042,6 +1051,7 @@ int frmMain::ReconnectServer(pgServer *server, bool restore)
                 item = server->GetId();
             browser->Thaw();
 
+			
             if (item)
             {
                 browser->SelectItem(item);
diff --git a/pgadmin/include/images/module.mk b/pgadmin/include/images/module.mk
index be7dd53..0409d3f 100644
--- a/pgadmin/include/images/module.mk
+++ b/pgadmin/include/images/module.mk
@@ -259,3 +259,4 @@ EXTRA_DIST += \
 	$(srcdir)/include/images/sql.ico \
 	$(srcdir)/include/images/sql.png
 
+include $(srcdir)/include/images/sv/module.mk
diff --git a/pgadmin/include/images/sv/column_changed_sm.xpm b/pgadmin/include/images/sv/column_changed_sm.xpm
new file mode 100644
index 0000000..eae0a33
--- /dev/null
+++ b/pgadmin/include/images/sv/column_changed_sm.xpm
@@ -0,0 +1,94 @@
+/* XPM */
+static const char *column_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 72 1",
+"V c #8C8E8B",
+"o c #1E336B",
+"k c #DAE9EC",
+"K c #505E8E",
+"P c #406580",
+": c #FFFFFF",
+"G c #C6FFFF",
+"q c #6D4E5C",
+"a c #152C64",
+"1 c #3182AC",
+"w c #6F7A96",
+"r c #092468",
+"# c #09246B",
+"2 c #9EFCFF",
+"% c #223569",
+"  c None",
+"x c #256586",
+"g c #E4FFFF",
+"7 c #525D82",
+"8 c #192E67",
+"B c #87838B",
+"H c #0D6AD2",
+"A c #4D76A0",
+"u c #9695BB",
+"y c #9DF4FF",
+"9 c #4E777F",
+"5 c #3A6168",
+"$ c #14739D",
+"d c #0C2763",
+". c #C2C6D1",
+"v c #76688A",
+"- c #A1FFFF",
+"L c #415C83",
+"n c #336698",
+"X c #525F83",
+"f c #20638D",
+"D c #C5FFFF",
+"U c #0764D1",
+"C c #B9BFB6",
+"N c #B7A2C4",
+"= c #176B97",
+"* c #193069",
+"< c #0A2468",
+"4 c #0A2469",
+"6 c #D6FFFF",
+"J c #0668A2",
+"+ c #6E7A96",
+"M c #C3FFFF",
+"i c #586A7F",
+", c #E7FFFF",
+"S c #156EAB",
+"F c #F8FFFF",
+"0 c #E5FFFF",
+"h c #FFFAFF",
+"; c #0B2569",
+"s c #0B256A",
+"b c #7F8E87",
+"l c #DEF2F0",
+"t c #3B82A6",
+"3 c #132A66",
+"> c #276F99",
+"e c #1D3269",
+"@ c #1D326B",
+"I c #42717C",
+"p c #2A3E65",
+"c c #F2FFFF",
+"Z c #DFFFFF",
+"& c #0C2360",
+"O c #0C266A",
+"z c #336BA3",
+"j c #DEE9F4",
+"m c #3E7A94",
+/* pixels */
+"       .XoOoX.  ",
+"      .+@O#O@+. ",
+"     $%&#####*X ",
+"    =-o;##::#Oo ",
+"    >,<##:####O ",
+"    1234#:###Oo ",
+"    5678##::#*X ",
+"    90qwe<#r@+. ",
+"    tyuipasdX.  ",
+"    fghjkl6z    ",
+"    xcv::b:n    ",
+"    mMNBVCZA    ",
+"    SD:::FGH    ",
+"     JKLPIU     ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/column_missing_sm.xpm b/pgadmin/include/images/sv/column_missing_sm.xpm
new file mode 100644
index 0000000..c16c396
--- /dev/null
+++ b/pgadmin/include/images/sv/column_missing_sm.xpm
@@ -0,0 +1,123 @@
+/* XPM */
+static const char *column_missing_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 101 2",
+"'  c #8C8E8B",
+"e  c #C3C9C9",
+"R  c #DAE9EC",
+"O. c #505E8E",
+"@. c #406580",
+"5  c #FFFFFF",
+"%  c #D41E1F",
+"g  c #FE0300",
+".. c #C6FFFF",
+">  c #FE0000",
+"u  c #FE0002",
+"<  c #FE0003",
+"1  c #FA0F0F",
+"p  c #3182AC",
+"v  c #A8655F",
+"@  c #C17F7F",
+"L  c #8DC7D3",
+"o  c #D3D3D3",
+"k  c #D51F1D",
+"a  c #9EFCFF",
+"P  c #2B5C88",
+"s  c #8697C7",
+"   c None",
+"j  c #FF0100",
+"9  c #FF0101",
+"=  c #6372A7",
+"8  c #FF0103",
+".  c #F9F9F9",
+"d  c #647C9E",
+"Q  c #256586",
+"U  c #E4FFFF",
+"b  c #EF0B0E",
+"i  c #F60304",
+"-  c #354F6F",
+"n  c #F91013",
+":  c #F7100E",
+"B  c #8F5F64",
+"`  c #87838B",
+"S  c #D41D1D",
+"X. c #0D6AD2",
+"J  c #778D94",
+",  c #FE0200",
+"{  c #4D76A0",
+"G  c #9695BB",
+"x  c #FFF5F9",
+"F  c #9DF4FF",
+"6  c #A4BDD3",
+"M  c #4E777F",
+"m  c #C17E7E",
+"l  c #3A6168",
+"w  c #585C90",
+"7  c #D01D1D",
+"*  c #14739D",
+"A  c #F50101",
+"#  c #D51E1E",
+"t  c #FEFFFA",
+"~  c #76688A",
+"4  c #A1FFFF",
+"+. c #415C83",
+"/  c #336698",
+"H  c #738493",
+"I  c #20638D",
+"|  c #C5FFFF",
+"$. c #0764D1",
+"]  c #B9BFB6",
+"h  c #FD0000",
+"_  c #B7A2C4",
+"3  c #176B97",
+"z  c #D6FFFF",
+"o. c #0668A2",
+"V  c #D7D7C8",
+")  c #C3FFFF",
+"&  c #C07F7F",
+"C  c #7D3F38",
+"q  c #E7FFFF",
+"+  c #D7D7D7",
+"}  c #156EAB",
+"y  c #FFFDFE",
+" . c #F8FFFF",
+"N  c #E5FFFF",
+"Y  c #FFFAFF",
+"$  c #F70305",
+"^  c #7F8E87",
+"O  c #C9C9C9",
+"2  c #C17D7E",
+"X  c #E7E7E7",
+"E  c #DEF2F0",
+"K  c #8CA6A3",
+"D  c #3B82A6",
+"0  c #276F99",
+"#. c #42717C",
+"!  c #F2FFFF",
+"c  c #E7D5C4",
+"r  c #F80403",
+"[  c #DFFFFF",
+"f  c #C41115",
+"W  c #336BA3",
+"Z  c #D31D1D",
+"T  c #DEE9F4",
+";  c #7F4A55",
+"(  c #3E7A94",
+/* pixels */
+"                . X o O o X .   ",
+"              . + @ # $ % & + . ",
+"          * = - ; : > , < 1 2 X ",
+"        3 4 5 6 7 8 > 8 > 9 # o ",
+"        0 q w e r < t y 5 u i O ",
+"        p a s d f g 9 8 h j k o ",
+"        l z x c v b h > > n m X ",
+"        M N B . V C Z A S @ + . ",
+"        D F G H J K L P o X .   ",
+"        I U Y T R E z W         ",
+"        Q ! ~ 5 5 ^ 5 /         ",
+"        ( ) _ ` ' ] [ {         ",
+"        } | 5 5 5  ...X.        ",
+"          o.O.+.@.#.$.          ",
+"                                ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/column_present_sm.xpm b/pgadmin/include/images/sv/column_present_sm.xpm
new file mode 100644
index 0000000..fa861c4
--- /dev/null
+++ b/pgadmin/include/images/sv/column_present_sm.xpm
@@ -0,0 +1,121 @@
+/* XPM */
+static const char *column_present_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 99 2",
+"f  c #0A7A00",
+"_  c #8C8E8B",
+"Y  c #DAE9EC",
+"X. c #505E8E",
+"O. c #406580",
+"3  c #087A00",
+"*  c #087A01",
+"H  c #475453",
+"r  c #FFFFFD",
+",  c #FFFFFF",
+"C  c #1A6A13",
+"|  c #C6FFFF",
+"B  c #186A12",
+"-  c #1C8414",
+"u  c #3182AC",
+"N  c #354C26",
+"x  c #0B7B0F",
+"=  c #097B01",
+"&  c #15800E",
+"t  c #097B02",
+"M  c #454540",
+"o  c #157D0B",
+"i  c #9EFCFF",
+"O  c #4D9F48",
+"p  c #8697C7",
+"+  c #BFDDBD",
+"   c None",
+"#  c #6372A7",
+"E  c #256586",
+"P  c #E4FFFF",
+"6  c #0A7901",
+"2  c #087C00",
+"n  c #8F5F64",
+")  c #87838B",
+"4  c #FFFEFF",
+" . c #0D6AD2",
+"m  c #B7B7B7",
+"y  c #127E0D",
+"$  c #3B577B",
+"]  c #4D76A0",
+"D  c #9695BB",
+"k  c #FFF5F9",
+"S  c #9DF4FF",
+"5  c #0B7A01",
+"d  c #0B7A02",
+"v  c #4E777F",
+"h  c #3A6168",
+"0  c #585C90",
+"@  c #14739D",
+".  c #C1DCBD",
+"K  c #19364F",
+"<  c #8EA4B7",
+"V  c #097702",
+"Q  c #76688A",
+"s  c #0F620E",
+">  c #A1FFFF",
+"o. c #415C83",
+"~  c #336698",
+"F  c #738493",
+"L  c #20638D",
+"{  c #C5FFFF",
+"w  c #0C7803",
+"@. c #0764D1",
+";  c #BDDCBC",
+"e  c #FCFFFF",
+"`  c #B9BFB6",
+"l  c #756C63",
+"(  c #B7A2C4",
+":  c #176B97",
+"G  c #58676D",
+"j  c #D6FFFF",
+".. c #0668A2",
+"c  c #1B810E",
+"/  c #C3FFFF",
+"7  c #4E9F47",
+"Z  c #93B091",
+"9  c #E7FFFF",
+"q  c #717575",
+"[  c #156EAB",
+"}  c #F8FFFF",
+"z  c #305536",
+"b  c #E5FFFF",
+"I  c #FFFAFF",
+"a  c #222A35",
+"!  c #7F8E87",
+"1  c #166B13",
+"T  c #DEF2F0",
+"A  c #3B82A6",
+"8  c #276F99",
+"g  c #4DA047",
+"+. c #42717C",
+"X  c #4DA048",
+"W  c #F2FFFF",
+"'  c #DFFFFF",
+"R  c #336BA3",
+"%  c #437260",
+"U  c #DEE9F4",
+"J  c #304347",
+"^  c #3E7A94",
+/* pixels */
+"                                ",
+"                  . X o O +     ",
+"          @ # $ % & * = = - ;   ",
+"        : > , < 1 2 3 4 5 6 7   ",
+"        8 9 0 q w 6 , e r t y   ",
+"        u i p a s d f r 5 * g   ",
+"        h j k l z x = 6 = c ;   ",
+"        v b n m M N B V C Z     ",
+"        A S D F G H J K m       ",
+"        L P I U Y T j R         ",
+"        E W Q , , ! , ~         ",
+"        ^ / ( ) _ ` ' ]         ",
+"        [ { , , , } |  .        ",
+"          ..X.o.O.+.@.          ",
+"                                ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/columns_changed_sm.xpm b/pgadmin/include/images/sv/columns_changed_sm.xpm
new file mode 100644
index 0000000..40b6ece
--- /dev/null
+++ b/pgadmin/include/images/sv/columns_changed_sm.xpm
@@ -0,0 +1,216 @@
+/* XPM */
+static const char *columns_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 194 2",
+"r. c #3794E4",
+" . c #04187B",
+"j  c #B0DEFF",
+"@  c #1C4B9D",
+"A  c #032B71",
+"u  c #EEFFF1",
+"8. c #233A70",
+"`  c #3594D6",
+"]. c #1698E6",
+"t. c #DEE0EC",
+"v  c #16256A",
+"J. c #F6D5C2",
+"^. c #339DE7",
+"N  c #359AF2",
+">. c #153254",
+":  c #DAE6E2",
+"-. c #0C1D75",
+"S  c #0D245A",
+"u. c #E3D5D2",
+"F  c #0F1B57",
+"c. c #E3DBEA",
+"E  c #081D5E",
+"+X c #1B8DD6",
+"%X c #4B86B2",
+"{  c #102B62",
+"I. c #168CE3",
+"<. c #EBE6EC",
+"'. c #F6FEEF",
+"}  c #0D216A",
+"d  c #979D99",
+"oX c #4798CF",
+";. c #102B6E",
+":. c #072A50",
+"I  c #E4DCD1",
+"R. c #E2EBF0",
+"9  c #148CE3",
+"J  c #061D6D",
+"_  c #E7E3D7",
+"C. c #2899E9",
+"+  c #1B81D3",
+"w. c #2D5377",
+"m. c #9FA8AF",
+"3. c #178DD5",
+"n  c #0B1E6A",
+"L. c #1C9DFF",
+"U. c #E0E8EA",
+"O. c #9A9B96",
+"V. c #3E94C7",
+"2  c #092471",
+"4  c #0D156A",
+"W. c #FBEACC",
+"=. c #0C255D",
+";  c #A8D2EA",
+"&. c #7084A5",
+"   c None",
+".. c #09247F",
+"<  c #8885A4",
+"z. c #F6E9E3",
+"@. c #D2ECFB",
+"6  c #435178",
+"O  c #0C9EFF",
+"). c #B4BFB9",
+"Y. c #B6B0A0",
+"g. c #D5EDED",
+"j. c #2696FA",
+"n. c #A7A7AF",
+"#. c #248DCF",
+"r  c #0A256A",
+"=  c #E6EDE6",
+"(. c #97B1AE",
+"G. c #E5E0F4",
+"_. c #B4B6B1",
+"T  c #063783",
+"0. c #123376",
+"!. c #9AC7E4",
+"|. c #D7D8DA",
+"~. c #2E8CC9",
+"H. c #E3DDE9",
+"]  c #1155A8",
+"W  c #0F2068",
+"w  c #2293F1",
+"$  c #142472",
+"{. c #E6E7F9",
+")  c #1B8FE2",
+"f. c #9CA6A8",
+"+. c #2794F1",
+"l. c #0B9CEF",
+"k. c #D3E4F6",
+"7. c #65779D",
+"L  c #42495C",
+"a. c #B0AD9C",
+"b. c #ABB2BC",
+"[. c #1992EB",
+"Z  c #072957",
+"l  c #132E65",
+"q. c #273B60",
+"D. c #F0DDDF",
+"m  c #243165",
+"K  c #152259",
+"*  c #778495",
+"p. c #DFDDF2",
+"Z. c #F5E4EE",
+"2. c #F1F0EC",
+"Q  c #EDFFF6",
+"C  c #F3DECD",
+"q  c #4F9CD2",
+"D  c #EDFFFF",
+"g  c #DBE0E4",
+"x. c #2692D3",
+"E. c #BBC5C4",
+"N. c #1F9DF1",
+"OX c #3E90CA",
+"a  c #132263",
+"G  c #091A62",
+"v. c #96ACBA",
+"x  c #EBFFFF",
+",  c #C7CADB",
+"4. c #FADCE8",
+"@X c #30A0F6",
+"6. c #AFC6D8",
+"1  c #123E7D",
+"B  c #D4D9DD",
+"s  c #3C495A",
+"%  c #202E5F",
+"y  c #071D66",
+"5  c #222E76",
+">  c #CDDBDE",
+"^  c #112874",
+"H  c #0A245F",
+"e  c #245AA2",
+"$X c #328EE1",
+"#  c #12356F",
+"d. c #F9ECE6",
+"!  c #E9FFFF",
+"P  c #2492E1",
+"5. c #2298E2",
+"i. c #2C9DDF",
+"*. c #19337D",
+"B. c #9AC9E7",
+"e. c #DCE1E5",
+"o  c #3893C0",
+"U  c #229BF8",
+"h  c #2298EF",
+".  c #2E94DE",
+"-  c #2CA0F5",
+"o. c #414A75",
+"/. c #EDE7F3",
+"|  c #14266E",
+"c  c #14205A",
+"0  c #E6E0D4",
+"3  c #142364",
+"y. c #1CAAF6",
+"X  c #2095DA",
+"Y  c #D0E2FA",
+"7  c #9196B6",
+" X c #FFFDFF",
+"M  c #62697B",
+"8  c #E4E6DB",
+"X. c #062156",
+"z  c #0B255E",
+"[  c #32356A",
+"A. c #2A9AE6",
+"h. c #2A8EBF",
+"P. c #E4ECFF",
+"#X c #1D88E8",
+"f  c #1B91F5",
+"%. c #2283D2",
+"k  c #2A507F",
+"p  c #081866",
+"Q. c #179DFC",
+"F. c #E6DAE6",
+".X c #F1F8FF",
+"T. c #F1F2ED",
+"b  c #132A60",
+"XX c #EAF7FF",
+"R  c #212360",
+"&  c #394A5C",
+"K. c #198EF5",
+"/  c #203049",
+"`. c #B1BCB8",
+"s. c #ECDFCF",
+"t  c #07286F",
+"(  c #616767",
+"9. c #07256B",
+"V  c #178BE2",
+"1. c #0E99F4",
+"'  c #CADCF0",
+"~  c #09227C",
+"M. c #DEE3DC",
+"S. c #DEE6E9",
+"$. c #DCECEB",
+"i  c #F0FFFA",
+"}. c #EBFBFB",
+",. c #919EA4",
+/* pixels */
+"      . X o O + @ # $ % & * =   ",
+"    - ; : > , < 1 2 3 4 5 6 7 8 ",
+"    9 0 q w e r t y u i p a s d ",
+"    f g h j k l z x c v b n m M ",
+"    N B V C Z A S D F G H J K L ",
+"    P I U Y T R E W Q ! ~ ^ / ( ",
+"    ) _ ` ' ] [ { } |  ...X.o.O.",
+"    +.@.#.$.%.&.*.=.-.;.:.>.,.<.",
+"    1.2.3.4.5.6.7.8.9.0.q.w.e.  ",
+"    r.t.y.u.i.p.a.s.d.f.g.h.    ",
+"    j.k.l.z.x.c.v.b.n.m.M.N.    ",
+"    B.V.C.Z.A.S.D.F.G.H.J.K.    ",
+"        L.P.I.U.Y.T.R.E.W.Q.    ",
+"        !.~.^./.(.)._.`.'.].    ",
+"            [.{.}.|. X.XXXoX    ",
+"              OX+X@X#X$X%X      "
+};
diff --git a/pgadmin/include/images/sv/constraints_changed_sm.xpm b/pgadmin/include/images/sv/constraints_changed_sm.xpm
new file mode 100644
index 0000000..84cee99
--- /dev/null
+++ b/pgadmin/include/images/sv/constraints_changed_sm.xpm
@@ -0,0 +1,107 @@
+/* XPM */
+static const char *constraints_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 85 1",
+"t c #C03D13",
+"K c #E5916D",
+"@ c #283E75",
+"v c #696969",
+"A c #C03A15",
+"P c #E66C45",
+"m c #8F5A44",
+"j c #E9B492",
+"X c #828FB4",
+"I c #BE3D13",
+"J c #BE3D15",
+"Y c #E77F5C",
+"* c #FFFFFF",
+"y c #E5BD9A",
+"5 c #BC3D10",
+"c c #9E9E9E",
+"a c #999DA8",
+"r c #67251B",
+"z c #C13E14",
+"= c #293F76",
+"0 c #152961",
+"2 c #384569",
+"T c #E76D44",
+"N c #C13B15",
+"Z c #E76D46",
+"% c #7481A6",
+"M c #CD7250",
+"( c #DA8D71",
+"6 c #E8BB9C",
+"S c #E7A281",
+"U c #BF3B14",
+"$ c #09246B",
+"G c #E56D48",
+"C c #E68058",
+"b c #351106",
+"  c None",
+"D c #E7936E",
+"o c #3E538B",
+"W c #E4805C",
+"w c #112056",
+"V c #E5936D",
+"p c #E3E3E3",
+"n c #5E4435",
+"< c #C03C15",
+"L c #E97E5C",
+"+ c #8C96B3",
+"u c #E9B092",
+"; c #D98B74",
+"1 c #D98B75",
+"- c #0D266A",
+": c #172B63",
+"# c #0D266B",
+"h c #BC3C17",
+") c #E5431C",
+"f c #8B5C51",
+"& c #273E77",
+"k c #E5A47E",
+"F c #E67F56",
+"i c #D88C72",
+"x c #D88C74",
+"_ c #D88C75",
+", c #C03B18",
+"8 c #878B96",
+"7 c #D98D75",
+"Q c #E46D42",
+"9 c #3F4A66",
+"s c #122055",
+"~ c #E34E24",
+"R c #E65B32",
+"g c #AB3513",
+". c #DADEE9",
+"q c #0B2569",
+"^ c #C13C13",
+"3 c #152A64",
+"E c #BF3C12",
+"B c #E7A080",
+"O c #132D71",
+"d c #333351",
+"e c #383448",
+"H c #BD3C12",
+"/ c #BD3C14",
+"> c #0C266A",
+"l c #E79170",
+"4 c #112159",
+"! c #E55C32",
+/* pixels */
+"       .XoOoX.  ",
+"      .+@#$#@+. ",
+"      %&$$**$&% ",
+"      =-$*$$$-= ",
+"      -$$*$$$$- ",
+"  ;   :>$$**$>: ",
+" ,<1  23$$$$$42 ",
+" 56,7 890q$qwer ",
+" tyu<ipa2:>sdfg ",
+" hjklzxpcvbnmMN ",
+" <BVCZ<  ASDFGH ",
+" JKLPI   7UYTR< ",
+" EWQN     7U!~^ ",
+" tP/       (U)t ",
+" _I         x<x ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/fk_changed_sm.xpm b/pgadmin/include/images/sv/fk_changed_sm.xpm
new file mode 100644
index 0000000..97b8cb0
--- /dev/null
+++ b/pgadmin/include/images/sv/fk_changed_sm.xpm
@@ -0,0 +1,96 @@
+/* XPM */
+static const char *fk_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 74 1",
+"m c #D9D9D9",
+"C c #3C3C3C",
+"V c #5A5A5A",
+"3 c #696969",
+"w c #B4B4B4",
+"X c #828FB4",
+"U c #D2D2D2",
+"a c #E1E1E1",
+"1 c #FFFFFF",
+"c c #5D616C",
+"7 c #8F8F8F",
+"; c #5D6A8F",
+", c #9E9E9E",
+"6 c #BCBCBC",
+"j c #152347",
+"u c #152961",
+"n c #797979",
+"P c #D3D3D3",
+"% c #09246B",
+"S c #BDBDBD",
+"F c #CCCCCC",
+"  c None",
+"p c #1B3169",
+"8 c #4D4D4D",
+"o c #3E538B",
+"K c #D4D4D4",
+"- c #E3E3E3",
+"0 c #142A64",
+"& c #0F296E",
+"s c #DCDCDC",
+"h c #2B2F3A",
+"z c #12275E",
+"e c #D5D5D5",
+"x c #2E3C60",
+"4 c #474747",
+"A c #838383",
+"v c #B0B0B0",
+"M c #CECECE",
+"9 c #273559",
+"> c #314680",
+"g c #7C7C7C",
+"J c #A9A9A9",
+"+ c #C2C6D1",
+"T c #848484",
+"Y c #B1B1B1",
+"= c #9DA7C4",
+"t c #2D313B",
+"l c #0A2468",
+"d c #D7D7D7",
+"< c #1C3169",
+"q c #858585",
+"G c #D0D0D0",
+"D c #DFDFDF",
+". c #DADEE9",
+": c #1A316B",
+"i c #0B2569",
+"y c #293451",
+"5 c #152A62",
+"2 c #10296D",
+"r c #6F6F6F",
+"H c #ABABAB",
+"N c #BABABA",
+"L c #D8D8D8",
+"k c #0E235A",
+"O c #132D71",
+"Z c #595959",
+"* c #364C84",
+"# c #1D326B",
+"B c #868686",
+"@ c #636D8A",
+"I c #B3B3B3",
+"f c #C2C2C2",
+"b c #E0E0E0",
+"$ c #0C266A",
+/* pixels */
+"       .XoOoX.  ",
+"      +@#$%&*=. ",
+"     -;:%%%%%>X ",
+"     ,<$%%11%2o ",
+"     3$%%1%%%%O ",
+"     45$%1%%%$o ",
+"  677890%%11%:X ",
+" qweertyui%ip@. ",
+"6wasdfghjklzxcv ",
+"7ebnmMNBVCZAS-n ",
+"7eDnmFGmHsJKLnv ",
+"6wDmPevnvnvnnv  ",
+" qIUGYT         ",
+"  6776          ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/fk_missing_sm.xpm b/pgadmin/include/images/sv/fk_missing_sm.xpm
new file mode 100644
index 0000000..2b3e714
--- /dev/null
+++ b/pgadmin/include/images/sv/fk_missing_sm.xpm
@@ -0,0 +1,91 @@
+/* XPM */
+static const char *fk_missing_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 69 1",
+"B c #D9D9D9",
+"a c #B4B4B4",
+"K c #D2D2D2",
+"k c #E1E1E1",
+"6 c #FFFFFF",
+"h c #D41E1D",
+"% c #D41E1F",
+"r c #8F8F8F",
+"9 c #FE0300",
+"g c #A8747E",
+"e c #BCBCBC",
+"z c #DADADA",
+"- c #FE0000",
+"7 c #FE0002",
+": c #FE0003",
+"> c #FA0F0F",
+"N c #797979",
+"@ c #C17F7F",
+"o c #D3D3D3",
+"w c #D51F1D",
+"F c #CCCCCC",
+"  c None",
+"q c #FF0100",
+"2 c #FF0101",
+"1 c #FF0103",
+". c #F9F9F9",
+"A c #D4D4D4",
+"S c #E3E3E3",
+"8 c #F60304",
+"u c #F91013",
+"b c #646464",
+"f c #828282",
+"l c #DCDCDC",
+"< c #D41D1D",
+"; c #FE0200",
+"s c #D5D5D5",
+"m c #B0B0B0",
+"* c #C17E7D",
+"i c #C17E7E",
+"V c #CECECE",
+"t c #AB747C",
+"# c #D51E1E",
+"J c #A9A9A9",
+"4 c #FEFFFA",
+"L c #848484",
+"x c #B1B1B1",
+"= c #F9120F",
+"0 c #FD0000",
+"n c #5F5F5F",
+"v c #6E6E6E",
+"& c #C07F7F",
+"+ c #D7D7D7",
+"5 c #FFFDFE",
+"c c #767676",
+"p c #858585",
+"G c #D0D0D0",
+"D c #DFDFDF",
+"j c #F70303",
+"$ c #F70305",
+"H c #ABABAB",
+"O c #C9C9C9",
+"Z c #D8D8D8",
+", c #C17D7E",
+"X c #E7E7E7",
+"d c #B3B3B3",
+"C c #D1D1D1",
+"M c #E0E0E0",
+"3 c #F80403",
+"y c #EF0C0F",
+/* pixels */
+"       .XoOoX.  ",
+"      .+@#$%&+. ",
+"      X*=-;:>,X ",
+"      o<1-1-2#o ",
+"      O3:45678O ",
+"      o<9210qwo ",
+"  erreXty0--uiX ",
+" passdf+ghj<@+. ",
+"eakl+zxcvbnbvcm ",
+"rsMNBVCZzZ+oASN ",
+"rsDNBFGBHlJAZNm ",
+"eaDBosmNmNmNNm  ",
+" pdKGxL         ",
+"  erre          ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/fk_present_sm.xpm b/pgadmin/include/images/sv/fk_present_sm.xpm
new file mode 100644
index 0000000..7ad996c
--- /dev/null
+++ b/pgadmin/include/images/sv/fk_present_sm.xpm
@@ -0,0 +1,94 @@
+/* XPM */
+static const char *fk_present_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 72 1",
+"C c #D9D9D9",
+"w c #0A7A00",
+"a c #B4B4B4",
+"I c #D2D2D2",
+": c #087A00",
+"$ c #087A01",
+"z c #E1E1E1",
+"6 c #FFFFFD",
+"4 c #FFFFFF",
+"0 c #1A6A13",
+"t c #8F8F8F",
+"r c #BCBCBC",
+"v c #DADADA",
+"j c #186A12",
+"- c #186A13",
+"& c #1C8414",
+"N c #797979",
+"D c #D3D3D3",
+"% c #097B01",
+"7 c #097B02",
+"g c #454545",
+"o c #157D0B",
+"y c #315B42",
+"O c #4D9F48",
+"J c #CCCCCC",
+"+ c #BFDDBD",
+"  c None",
+"# c #188110",
+"F c #D4D4D4",
+"G c #E3E3E3",
+"< c #0A7901",
+"; c #087C00",
+"x c #DCDCDC",
+"> c #FFFEFF",
+"= c #B7B7B7",
+"8 c #127E0D",
+"s c #D5D5D5",
+"m c #383838",
+"9 c #474747",
+", c #0B7A01",
+"q c #0B7A02",
+"B c #B0B0B0",
+"Z c #CECECE",
+"M c #222222",
+". c #C1DCBD",
+"P c #A9A9A9",
+"n c #575757",
+"2 c #757575",
+"U c #848484",
+"@ c #90AF8F",
+"b c #B1B1B1",
+"* c #BDDCBC",
+"5 c #FCFFFF",
+"f c #5F5F5F",
+"i c #1B810E",
+"1 c #4E9F47",
+"l c #93B091",
+"c c #D7D7D7",
+"h c #466243",
+"p c #858585",
+"3 c #0D7903",
+"K c #D0D0D0",
+"H c #DFDFDF",
+"u c #0B7C10",
+"L c #ABABAB",
+"S c #D8D8D8",
+"e c #4DA047",
+"X c #4DA048",
+"d c #B3B3B3",
+"A c #D1D1D1",
+"V c #E0E0E0",
+"k c #0C7A04",
+/* pixels */
+"                ",
+"        .XoO+   ",
+"       @#$%%&*  ",
+"      =-;:>,<1  ",
+"      23<45678  ",
+"      90qw6,$e  ",
+"  rttr2yu%<%i*  ",
+" passdfghjk0l   ",
+"razxcvbnmMmnNNB ",
+"tsVNCZASvScDFGN ",
+"tsHNCJKCLxPFSNB ",
+"raHCDsBNBNBNNB  ",
+" pdIKbU         ",
+"  rttr          ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/green.xpm b/pgadmin/include/images/sv/green.xpm
new file mode 100644
index 0000000..05edd6d
--- /dev/null
+++ b/pgadmin/include/images/sv/green.xpm
@@ -0,0 +1,22 @@
+/* XPM */
+static const char *green_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"15 13 3 1",
+"X c #83983D",
+". c #84993E",
+"  c #859A3F",
+/* pixels */
+" .X.  .........",
+".  ............",
+"X   ....       ",
+"..  ...........",
+" ... .. .......",
+" ...... .......",
+"...............",
+"....  ..       ",
+"...............",
+"...............",
+"...............",
+"........       ",
+"..............."
+};
diff --git a/pgadmin/include/images/sv/index_changed_sm.xpm b/pgadmin/include/images/sv/index_changed_sm.xpm
new file mode 100644
index 0000000..da8aabe
--- /dev/null
+++ b/pgadmin/include/images/sv/index_changed_sm.xpm
@@ -0,0 +1,123 @@
+/* XPM */
+static const char *index_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 101 2",
+"j  c #0A235F",
+"@  c #283E75",
+"{  c #3F4F5D",
+"~  c #A1C9EA",
+"X  c #828FB4",
+"r  c #2B3F67",
+"z  c #C9E6F5",
+"4  c #0B6EB8",
+",  c #FFFFFF",
+"2  c #2178C6",
+"K  c #29333A",
+"s  c #4C5861",
+"L  c #1A2127",
+"Z  c #999DA8",
+"f  c #152341",
+"6  c #0B2460",
+"g  c #0B2159",
+":  c #293F76",
+"'  c #45545F",
+"F  c #4A5860",
+"d  c #63788F",
+"u  c #384569",
+"5  c #357FD3",
+"%  c #7481A6",
+"M  c #273C66",
+"w  c #C5E3F4",
+"$  c #09246B",
+"<  c #337FD1",
+"   c None",
+"}  c #99C3E7",
+"=  c #317FD1",
+"C  c #0F2C61",
+"o  c #3E538B",
+"|  c #BCDCF2",
+"e  c #C1E0F3",
+"x  c #C6E4F5",
+"A  c #E3E3E3",
+"_  c #495660",
+"a  c #4E5A61",
+"$. c #88B4E5",
+"!  c #A6CCEB",
+"S  c #4E5A62",
+"Q  c #ABD0ED",
+"W  c #B0D4EE",
+"+  c #8C96B3",
+"(  c #95C0E6",
+">  c #0D266A",
+"9  c #172B63",
+"#  c #0D266B",
+"c  c #C2E1F4",
+";  c #1F77C4",
+"^  c #9DC5E9",
+"p  c #4F5B62",
+"]  c #A7CDEC",
+"-  c #297CCB",
+"&  c #273E77",
+"h  c #092368",
+"3  c #1673BF",
+"P  c #11161A",
+"b  c #B9DAF1",
+"v  c #BEDEF2",
+"Y  c #C3E2F4",
+"1  c #2C7DCD",
+"V  c #112861",
+"N  c #112862",
+"t  c #112864",
+"[  c #41505E",
+")  c #4B5860",
+"/  c #99C2E7",
+"+. c #9EC6E9",
+"O. c #A3CAEA",
+"i  c #505C62",
+"0  c #CBE7F6",
+"I  c #3F505F",
+"7  c #0A2469",
+"l  c #878B96",
+"H  c #B0D3EE",
+"R  c #BADBF1",
+"T  c #BFDFF3",
+"m  c #6A839E",
+"k  c #3F4A66",
+"@. c #9AC3E8",
+"`  c #475560",
+"D  c #4C5961",
+"J  c #3D4A55",
+".  c #DADEE9",
+"B  c #0B256A",
+"y  c #152A64",
+"E  c #B6D8F0",
+"O  c #132D71",
+"#. c #96C0E7",
+"G  c #485660",
+"*  c #89ABDF",
+"n  c #A0BFD5",
+"U  c #214F83",
+"q  c #C8E5F5",
+"8  c #0C266A",
+"o. c #A8CDEC",
+"X. c #ADD1ED",
+".. c #B2D5EF",
+" . c #B7D9F0",
+/* pixels */
+"                                ",
+"                . X o O o X .   ",
+"              . + @ # $ # @ + . ",
+"              % & $ $ $ $ $ & % ",
+"    * = - ;   : > $ $ , , $ > : ",
+"    < 1 2 3 4 > $ $ , $ $ $ $ > ",
+"    5 5 5 5 5 6 7 $ , $ $ $ 8 9 ",
+"  5 0 0 q w e r t $ $ , , $ y u ",
+"  5 0 i p a s d f g h $ 7 j k l ",
+"  5 z x c v b n m M N B V C Z A ",
+"  5 x S D F G H J K L P I U A   ",
+"  5 Y T R E W Q ! ~ ^ / ( 5     ",
+"  5 T ) _ ` ' ] [ { } ( 5       ",
+"  5 |  ...X.o.O.+.@.#.5 $.      ",
+"  $.5 5 5 5 5 5 5 5 5 $.        ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/index_missing_sm.xpm b/pgadmin/include/images/sv/index_missing_sm.xpm
new file mode 100644
index 0000000..a212447
--- /dev/null
+++ b/pgadmin/include/images/sv/index_missing_sm.xpm
@@ -0,0 +1,136 @@
+/* XPM */
+static const char *index_missing_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 114 2",
+"&. c #3F4F5D",
+"^  c #44535F",
+" . c #A1C9EA",
+"P  c #ABCEE8",
+"Y  c #7E9EB8",
+"F  c #C9E6F5",
+"z  c #ABC8DB",
+"q  c #0B6EB8",
+"C  c #623341",
+"t  c #FFFFFF",
+"9  c #2178C6",
+"%  c #D41E1F",
+"V  c #3D4951",
+"N  c #4C5861",
+"I  c #9ABCD6",
+"s  c #FE0300",
+"-  c #FE0000",
+"y  c #FE0002",
+":  c #FE0003",
+"#. c #45545F",
+"_  c #98C2E7",
+"(  c #40505E",
+"Q  c #4A5860",
+">  c #FA0F0F",
+"i  c #357FD3",
+"@  c #C17F7F",
+"k  c #C5E3F4",
+"o  c #D3D3D3",
+"7  c #337FD1",
+"L  c #B4D7EF",
+"   c None",
+"f  c #FF0100",
+"6  c #FF0101",
+"5  c #FF0103",
+".  c #F9F9F9",
+"*. c #99C3E7",
+"1  c #317FD1",
+"c  c #EF0B0E",
+"=. c #BCDCF2",
+"l  c #C1E0F3",
+"G  c #C6E4F5",
+"u  c #F60304",
+"p  c #2C69AF",
+"+. c #495660",
+"M  c #4E5A61",
+"3. c #88B4E5",
+"|  c #A6CCEB",
+"E  c #4E5A62",
+"}  c #ABD0ED",
+"{  c #B0D4EE",
+"B  c #B5D5EB",
+"o. c #95C0E6",
+"/  c #42525E",
+"4  c #D41D1D",
+";  c #FE0200",
+"H  c #C2E1F4",
+"Z  c #BE0A0B",
+"3  c #1F77C4",
+"D  c #744E6E",
+".. c #9DC5E9",
+"m  c #4F5B62",
+"$. c #A7CDEC",
+"2  c #297CCB",
+"*  c #C17E7D",
+"A  c #F50101",
+")  c #3E4F5D",
+"g  c #D51E1D",
+"#  c #D51E1E",
+"0  c #1673BF",
+"K  c #B9DAF1",
+"J  c #BEDEF2",
+"`  c #C3E2F4",
+"e  c #FEFFFA",
+"8  c #2C7DCD",
+"S  c #C9161A",
+"%. c #41505E",
+"O. c #4B5860",
+"X. c #99C2E7",
+"<. c #9EC6E9",
+",. c #A3CAEA",
+"n  c #505C62",
+"=  c #F9120F",
+"d  c #FD0000",
+"h  c #CBE7F6",
+"a  c #BD0E18",
+"~  c #B0D3EE",
+"]  c #BADBF1",
+"&  c #C07F7F",
+"'  c #BFDFF3",
+"+  c #D7D7D7",
+"v  c #F70F12",
+"1. c #9AC3E8",
+"@. c #475560",
+"W  c #4C5961",
+"r  c #FFFDFE",
+"T  c #81A3C0",
+"$  c #F70305",
+"[  c #B6D8F0",
+"U  c #89A8C2",
+"O  c #C9C9C9",
+"b  c #C17D7D",
+"R  c #3073BF",
+",  c #C17D7E",
+"X  c #E7E7E7",
+"x  c #906576",
+"2. c #96C0E7",
+"!  c #485660",
+"<  c #89ABDF",
+"j  c #C8E5F5",
+"w  c #F80403",
+">. c #A8CDEC",
+":. c #ADD1ED",
+";. c #B2D5EF",
+"-. c #B7D9F0",
+/* pixels */
+"                                ",
+"                . X o O o X .   ",
+"              . + @ # $ % & + . ",
+"              X * = - ; : > , X ",
+"    < 1 2 3   o 4 5 - 5 - 6 # o ",
+"    7 8 9 0 q O w : e r t y u O ",
+"    i i i i i p a s 6 5 d f g o ",
+"  i h h j k l z x c d - - v b X ",
+"  i h n m M N B V C Z A S D + . ",
+"  i F G H J K L P I U Y T R .   ",
+"  i G E W Q ! ~ ^ / ( ) _ i     ",
+"  i ` ' ] [ { } |  ...X.o.i     ",
+"  i ' O.+.@.#.$.%.&.*.o.i       ",
+"  i =.-.;.:.>.,.<.1.2.i 3.      ",
+"  3.i i i i i i i i i 3.        ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/index_present_sm.xpm b/pgadmin/include/images/sv/index_present_sm.xpm
new file mode 100644
index 0000000..a438f39
--- /dev/null
+++ b/pgadmin/include/images/sv/index_present_sm.xpm
@@ -0,0 +1,133 @@
+/* XPM */
+static const char *index_present_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 111 2",
+"M  c #859CAD",
+"d  c #0A7A00",
+"#. c #3F4F5D",
+"Q  c #44535F",
+"{  c #A1C9EA",
+"S  c #C9E6F5",
+"0  c #0B6EB8",
+"1  c #087A00",
+"$  c #087A01",
+"V  c #0B5E07",
+"t  c #FFFFFD",
+"e  c #FFFFFF",
+"8  c #2178C6",
+"m  c #4C5861",
+"Z  c #136612",
+",  c #186A13",
+"O. c #45545F",
+"/  c #98C2E7",
+"~  c #40505E",
+"R  c #4A5860",
+"&  c #1C8414",
+"N  c #13171A",
+"i  c #357FD3",
+"U  c #708DA6",
+"j  c #C5E3F4",
+"%  c #097B01",
+"y  c #097B02",
+"o  c #157D0B",
+"B  c #29472A",
+"6  c #337FD1",
+"O  c #4D9F48",
+"J  c #B4D7EF",
+"+  c #BFDDBD",
+"   c None",
+"p  c #0F233B",
+"#  c #188110",
+"$. c #99C3E7",
+"-  c #317FD1",
+"%. c #BCDCF2",
+"k  c #C1E0F3",
+"D  c #C6E4F5",
+"I  c #495C6B",
+"4  c #0A7901",
+"X. c #495660",
+"n  c #4E5A61",
+"<. c #88B4E5",
+"[  c #A6CCEB",
+"Y  c #4E5A62",
+"]  c #ABD0ED",
+"'  c #B0D4EE",
+"<  c #087C00",
+"K  c #7E97AB",
+"z  c #26543F",
+" . c #95C0E6",
+"!  c #42525E",
+"2  c #FFFEFF",
+"P  c #2E3941",
+"F  c #C2E1F4",
+">  c #B7B7B7",
+"A  c #38767D",
+"u  c #127E0D",
+":  c #1F77C4",
+"3  c #0B7A01",
+"s  c #0B7A02",
+"}  c #9DC5E9",
+"b  c #4F5B62",
+"+. c #A7CDEC",
+";  c #297CCB",
+"a  c #0C610F",
+"^  c #3E4F5D",
+".  c #C1DCBD",
+"C  c #097702",
+"9  c #1673BF",
+"H  c #B9DAF1",
+"G  c #BEDEF2",
+"(  c #C3E2F4",
+"7  c #2C7DCD",
+"@. c #41505E",
+".. c #4B5860",
+"|  c #99C2E7",
+":. c #9EC6E9",
+";. c #A3CAEA",
+"v  c #505C62",
+"q  c #757575",
+"@  c #90AF8F",
+"w  c #0C7803",
+"*  c #BDDCBC",
+"r  c #FCFFFF",
+"g  c #CBE7F6",
+"L  c #4E5F6C",
+"x  c #0A7B0F",
+"5  c #4E9F47",
+"W  c #B0D3EE",
+"_  c #BADBF1",
+")  c #BFDFF3",
+">. c #9AC3E8",
+"o. c #475560",
+"T  c #4C5961",
+"`  c #B6D8F0",
+",. c #96C0E7",
+"E  c #485660",
+"f  c #4DA047",
+"X  c #4DA048",
+"l  c #57656F",
+"=  c #89ABDF",
+"h  c #C8E5F5",
+"c  c #187F0D",
+"-. c #A8CDEC",
+"=. c #ADD1ED",
+"*. c #B2D5EF",
+"&. c #B7D9F0",
+/* pixels */
+"                                ",
+"                                ",
+"                  . X o O +     ",
+"                @ # $ % % & *   ",
+"    = - ; :   > , < 1 2 3 4 5   ",
+"    6 7 8 9 0 q w 4 e r t y u   ",
+"    i i i i i p a s d t 3 $ f   ",
+"  i g g h j k l z x % 4 % c *   ",
+"  i g v b n m M N B V C Z A     ",
+"  i S D F G H J K L P I U i     ",
+"  i D Y T R E W Q ! ~ ^ / i     ",
+"  i ( ) _ ` ' ] [ { } |  .i     ",
+"  i ) ..X.o.O.+.@.#.$. .i       ",
+"  i %.&.*.=.-.;.:.>.,.i <.      ",
+"  <.i i i i i i i i i <.        ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/indexes_changed_sm.xpm b/pgadmin/include/images/sv/indexes_changed_sm.xpm
new file mode 100644
index 0000000..730f30a
--- /dev/null
+++ b/pgadmin/include/images/sv/indexes_changed_sm.xpm
@@ -0,0 +1,137 @@
+/* XPM */
+static const char *indexes_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 115 2",
+"d  c #CBE6F7",
+"0  c #283E78",
+"!  c #303D49",
+"<  c #8C97B2",
+"=  c #1773C0",
+"m  c #347ED3",
+"@  c #828FB3",
+"k  c #C9E6F4",
+"g  c #347ED5",
+"T  c #1D497F",
+"9  c #FFFFFF",
+"p  c #0D276B",
+".  c #88ACDE",
+" . c #2E3A41",
+"o. c #86ACCE",
+"Y  c #293C61",
+"3  c #377FD3",
+"D  c #C2DFF1",
+"*  c #1F78C8",
+"(  c #0B215A",
+"$. c #40505D",
+"%. c #40505F",
+"O  c #1D78BF",
+"8  c #0E2E72",
+"h  c #357FD4",
+"J  c #CAE7F5",
+",  c #09246B",
+")  c #11234A",
+"`  c #2E72BD",
+"H  c #3880D4",
+"   c None",
+"_  c #5F7B9A",
+"X  c #317FD2",
+"C  c #0F2C61",
+"#  c #3E538B",
+"1  c #8AB4E6",
+">. c #ADD0EE",
+"~  c #14244A",
+"x  c #CBE5F2",
+"I  c #0A2569",
+"j  c #0A256A",
+"e  c #CBE5F4",
+"R  c #88B4E1",
+":  c #283D76",
+"3. c #88B4E5",
+"q  c #7382A6",
+"4  c #3480D4",
+"*. c #3480D6",
+"G  c #C9E5F3",
+"-. c #BDE0F3",
+"t  c #C2E1F3",
+"u  c #1F3974",
+"U  c #102761",
+"'  c #C2DEF3",
+"E  c #377ED6",
+"a  c #293E76",
+"2. c #89B5E6",
+"#. c #ACD1EE",
+"K  c #6D7F92",
+"L  c #314363",
+"M  c #C5E2F2",
+"X. c #617A90",
+"[  c #C5E2F4",
+"-  c #0C6EB9",
+"/  c #092368",
+"=. c #87B5E6",
+".. c #435361",
+"|  c #485762",
+";  c #8B97B3",
+"%  c #818FB4",
+"S  c #203765",
+"&  c #2C7DCC",
+"P  c #112862",
+"n  c #162C63",
+"}  c #738794",
+"@. c #46545F",
+"+. c #4B5860",
+":. c #B2D6F0",
+"N  c #CBE7F5",
+"A  c #0A2462",
+"Z  c #0A2463",
+"o  c #287DCD",
+"l  c #347FD2",
+"^  c #122962",
+"w  c #CEE8F7",
+",. c #A4CBEA",
+"O. c #4C5961",
+";. c #B8DBF1",
+"]  c #C7E7F4",
+"&. c #9AC0E7",
+"{  c #A9C6D8",
+"z  c #CCE8F6",
+"+  c #DADEE9",
+"4. c #377DD2",
+"b  c #0B2569",
+"V  c #3580D3",
+"7  c #1B4A93",
+"f  c #73AAE2",
+"1. c #96C3E4",
+"6  c #357DD1",
+"2  c #357DD2",
+"v  c #132A63",
+"$  c #132D71",
+"F  c #3380D0",
+"s  c #3380D2",
+"W  c #C3E4F5",
+"B  c #71A7E3",
+"c  c #C8E5F5",
+"Q  c #465355",
+"i  c #0C266A",
+">  c #0C266B",
+"y  c #BCDDF0",
+"<. c #9EC5EC",
+"r  c #C6E5F7",
+"5  c #367ED0",
+/* pixels */
+"                                ",
+"                                ",
+"  . X o O     + @ # $ # % +     ",
+"  X & * = - + ; : > , > : < +   ",
+"1 2 3 4 5 6 7 8 , , 9 9 , 0 q   ",
+"5 w e r t y u i , 9 , , , p a   ",
+"s d f g 4 h j , , 9 , , , , p   ",
+"4 k l z x c v b , , 9 9 , b n   ",
+"m M m N B V C Z , , , , , A S   ",
+"h D F G H J K L P I , I U Y T   ",
+"R 4 E W l N Q ! ~ ^ / ( ) _ `   ",
+"    l ' s ] [ { } |  ...X.o.4   ",
+"      l h M O.+.@.#.$.%.&.*.=.  ",
+"        h -.;.:.>.,.<.1.l 2.    ",
+"        3.V F m 4 4.s h 2.      ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/module.mk b/pgadmin/include/images/sv/module.mk
new file mode 100644
index 0000000..b61498a
--- /dev/null
+++ b/pgadmin/include/images/sv/module.mk
@@ -0,0 +1,54 @@
+#######################################################################
+#
+# pgAdmin III - PostgreSQL Tools
+# $Id: module.mk 8323 2010-04-30 07:44:18Z dpage $
+# Copyright (C) 2002 - 2010, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# module.mk -	 $(srcdir)/include/images/ Makefile fragment
+#
+#######################################################################
+
+pgadmin3_SOURCES += \
+	$(srcdir)/include/images/sv/column_changed_sm.xpm \
+	$(srcdir)/include/images/sv/column_missing_sm.xpm \
+	$(srcdir)/include/images/sv/column_present_sm.xpm \
+	$(srcdir)/include/images/sv/columns_changed_sm.xpm \
+	$(srcdir)/include/images/sv/constraints_changed_sm.xpm \
+	$(srcdir)/include/images/sv/fk_missing_sm.xpm \
+	$(srcdir)/include/images/sv/fk_present_sm.xpm \
+	$(srcdir)/include/images/sv/fk_changed_sm.xpm \
+	$(srcdir)/include/images/sv/indexes_changed_sm.xpm \
+	$(srcdir)/include/images/sv/index_missing_sm.xpm \
+	$(srcdir)/include/images/sv/index_present_sm.xpm \
+	$(srcdir)/include/images/sv/index_changed_sm.xpm \
+	$(srcdir)/include/images/sv/pk_changed_sm.xpm \
+	$(srcdir)/include/images/sv/pk_missing_sm.xpm \
+	$(srcdir)/include/images/sv/pk_present_sm.xpm \
+	$(srcdir)/include/images/sv/rule_changed_sm.xpm \
+	$(srcdir)/include/images/sv/rule_missing_sm.xpm \
+	$(srcdir)/include/images/sv/rule_present_sm.xpm \
+	$(srcdir)/include/images/sv/rules_changed_sm.xpm \
+	$(srcdir)/include/images/sv/schemas_changed_sm.xpm \
+	$(srcdir)/include/images/sv/schema_missing_sm.xpm \
+	$(srcdir)/include/images/sv/schema_present_sm.xpm \
+	$(srcdir)/include/images/sv/schema_changed_sm.xpm \
+	$(srcdir)/include/images/sv/tables_changed_sm.xpm \
+	$(srcdir)/include/images/sv/table_missing_sm.xpm \
+	$(srcdir)/include/images/sv/table_present_sm.xpm \
+	$(srcdir)/include/images/sv/table_changed_sm.xpm \
+	$(srcdir)/include/images/sv/unique_missing_sm.xpm \
+	$(srcdir)/include/images/sv/unique_present_sm.xpm \
+	$(srcdir)/include/images/sv/unique_changed_sm.xpm \
+	$(srcdir)/include/images/sv/views_changed_sm.xpm \
+	$(srcdir)/include/images/sv/view_missing_sm.xpm \
+	$(srcdir)/include/images/sv/view_present_sm.xpm \
+	$(srcdir)/include/images/sv/view_changed_sm.xpm 
+	
+	
+	
+	
+	
+
+EXTRA_DIST += \
+	$(srcdir)/include/sv/images/module.mk 
diff --git a/pgadmin/include/images/sv/pk_changed_sm.xpm b/pgadmin/include/images/sv/pk_changed_sm.xpm
new file mode 100644
index 0000000..e50ad38
--- /dev/null
+++ b/pgadmin/include/images/sv/pk_changed_sm.xpm
@@ -0,0 +1,108 @@
+/* XPM */
+static const char *pk_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 86 1",
+"l c #FFF3B5",
+", c #FFFFE0",
+"z c #FFFFE6",
+"D c #B9A058",
+"o c #1E336B",
+"h c #FFFFEE",
+"m c #80650D",
+"Z c #C0B52D",
+"> c #FFFFF1",
+"U c #D9C633",
+"p c #FFFFFD",
+"b c #FFFFFE",
+"K c #FBE47B",
+"% c #FFFFFF",
+"u c #97946E",
+"/ c #BFBA91",
+"3 c #C9BC8D",
+"R c #786B00",
+"k c #F4E9AC",
+"# c #09246B",
+"- c #BDAB78",
+"  c None",
+"( c #6B654C",
+"; c #665B37",
+"< c #DBCCAA",
+"T c #EADD43",
+"n c #EDD996",
+"S c #AF973B",
+"4 c #FFF2B3",
+"A c #F1DE63",
+"W c #BC9D2D",
+"w c #172B5B",
+") c #CEC588",
+"a c #604C09",
+"6 c #ECD47A",
+"i c #EEDDB1",
+"r c #102454",
+"E c #A59103",
+": c #D8D0A7",
+"y c #928969",
+"G c #C4B482",
+"C c #AA9511",
+"t c #313A41",
+"q c #2C333C",
+"Y c #877300",
+"I c #7A6100",
+"* c #817141",
+"= c #908050",
+"B c #FFE86E",
+"M c #FFF18D",
+"L c #FFE56B",
+". c #C2C6D1",
+"` c #968E54",
+"c c #A79A6D",
+"d c #C0A862",
+"8 c #E6D176",
+"X c #525F83",
+"1 c #5C4C30",
+"$ c #193069",
+"e c #0A2467",
+"P c #F6DE5B",
+"x c #F8EA98",
+"v c #7D7459",
+"+ c #6E7A96",
+"g c #F0D993",
+"& c #BAAE7A",
+"^ c #FBF7CE",
+"9 c #958024",
+"N c #FFFF93",
+"! c #AEA976",
+"V c #FFFF9F",
+"J c #FFFFB1",
+"@ c #1D326B",
+"5 c #FFFFB7",
+"f c #FFFCB4",
+"Q c #A29B72",
+"H c #FFFFC2",
+"2 c #DEDAB5",
+"_ c #8C854B",
+"j c #FFF9B7",
+"O c #0C266A",
+"7 c #FFFFCD",
+"0 c #504310",
+"F c #DED7BB",
+"~ c #FFFFDA",
+"s c #FFFFDB",
+/* pixels */
+"        .XoOoX. ",
+"       .+@O#O@+.",
+"       X$#####$X",
+"       oO##%%#Oo",
+"       O##%####O",
+"       oO#%###Oo",
+"  &*=- X$##%%#$X",
+" ;:>,<1.+@O#O@+.",
+"234567890qwerty ",
+"uipasdfghjklzxc ",
+"vbnmMNBVCNZNASD ",
+"FGHJKLPIUYTREW  ",
+" Q!~^/(         ",
+"  )_`           ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/pk_changed_sm.xpm.bak b/pgadmin/include/images/sv/pk_changed_sm.xpm.bak
new file mode 100644
index 0000000..a3003fa
--- /dev/null
+++ b/pgadmin/include/images/sv/pk_changed_sm.xpm.bak
@@ -0,0 +1,108 @@
+/* XPM */
+static char *pk_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 86 1",
+"l c #FFF3B5",
+", c #FFFFE0",
+"z c #FFFFE6",
+"D c #B9A058",
+"o c #1E336B",
+"h c #FFFFEE",
+"m c #80650D",
+"Z c #C0B52D",
+"> c #FFFFF1",
+"U c #D9C633",
+"p c #FFFFFD",
+"b c #FFFFFE",
+"K c #FBE47B",
+"% c #FFFFFF",
+"u c #97946E",
+"/ c #BFBA91",
+"3 c #C9BC8D",
+"R c #786B00",
+"k c #F4E9AC",
+"# c #09246B",
+"- c #BDAB78",
+"  c None",
+"( c #6B654C",
+"; c #665B37",
+"< c #DBCCAA",
+"T c #EADD43",
+"n c #EDD996",
+"S c #AF973B",
+"4 c #FFF2B3",
+"A c #F1DE63",
+"W c #BC9D2D",
+"w c #172B5B",
+") c #CEC588",
+"a c #604C09",
+"6 c #ECD47A",
+"i c #EEDDB1",
+"r c #102454",
+"E c #A59103",
+": c #D8D0A7",
+"y c #928969",
+"G c #C4B482",
+"C c #AA9511",
+"t c #313A41",
+"q c #2C333C",
+"Y c #877300",
+"I c #7A6100",
+"* c #817141",
+"= c #908050",
+"B c #FFE86E",
+"M c #FFF18D",
+"L c #FFE56B",
+". c #C2C6D1",
+"` c #968E54",
+"c c #A79A6D",
+"d c #C0A862",
+"8 c #E6D176",
+"X c #525F83",
+"1 c #5C4C30",
+"$ c #193069",
+"e c #0A2467",
+"P c #F6DE5B",
+"x c #F8EA98",
+"v c #7D7459",
+"+ c #6E7A96",
+"g c #F0D993",
+"& c #BAAE7A",
+"^ c #FBF7CE",
+"9 c #958024",
+"N c #FFFF93",
+"! c #AEA976",
+"V c #FFFF9F",
+"J c #FFFFB1",
+"@ c #1D326B",
+"5 c #FFFFB7",
+"f c #FFFCB4",
+"Q c #A29B72",
+"H c #FFFFC2",
+"2 c #DEDAB5",
+"_ c #8C854B",
+"j c #FFF9B7",
+"O c #0C266A",
+"7 c #FFFFCD",
+"0 c #504310",
+"F c #DED7BB",
+"~ c #FFFFDA",
+"s c #FFFFDB",
+/* pixels */
+"        .XoOoX. ",
+"       .+@O#O@+.",
+"       X$#####$X",
+"       oO##%%#Oo",
+"       O##%####O",
+"       oO#%###Oo",
+"  &*=- X$##%%#$X",
+" ;:>,<1.+@O#O@+.",
+"234567890qwerty ",
+"uipasdfghjklzxc ",
+"vbnmMNBVCNZNASD ",
+"FGHJKLPIUYTREW  ",
+" Q!~^/(         ",
+"  )_`           ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/pk_missing_sm.xpm b/pgadmin/include/images/sv/pk_missing_sm.xpm
new file mode 100644
index 0000000..1d7c22e
--- /dev/null
+++ b/pgadmin/include/images/sv/pk_missing_sm.xpm
@@ -0,0 +1,136 @@
+/* XPM */
+static const char *pk_missing_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 114 2",
+"R  c #FFF3B5",
+"g  c #FFFFE0",
+"E  c #FFFFE6",
+"}  c #B9A058",
+"U  c #FFFFEE",
+"/  c #80650D",
+"]  c #C0B52D",
+"f  c #FFFFF1",
+"#. c #D9C633",
+"H  c #FFFFFD",
+"~  c #FFFFFE",
+"D  c #AD9E6B",
+"o. c #FBE47B",
+"6  c #FFFFFF",
+"l  c #D41E1D",
+"%  c #D41E1F",
+"F  c #97946E",
+"9  c #FE0300",
+",. c #BFBA91",
+"k  c #A8747E",
+"-  c #FE0000",
+"7  c #FE0002",
+":  c #FE0003",
+"B  c #685200",
+"c  c #C9BC8D",
+">  c #FA0F0F",
+"&. c #786B00",
+"T  c #F4E9AC",
+"@  c #C17F7F",
+"o  c #D3D3D3",
+"w  c #D51F1D",
+"y  c #BDAB78",
+"   c None",
+"<. c #6B654C",
+"s  c #665B37",
+"q  c #FF0100",
+"h  c #DBCCAA",
+"2  c #FF0101",
+"1  c #FF0103",
+".  c #F9F9F9",
+"%. c #EADD43",
+"^  c #EDD996",
+"{  c #AF973B",
+"v  c #FFF2B3",
+"8  c #F60304",
+"[  c #F1DE63",
+"p  c #F91013",
+"=. c #BC9D2D",
+"1. c #CEC588",
+"<  c #D41D1D",
+"J  c #604C09",
+"n  c #ECD47A",
+";  c #FE0200",
+"G  c #EEDDB1",
+"*. c #A59103",
+"d  c #D8D0A7",
+" . c #C4B482",
+"'  c #AA9511",
+"*  c #C17E7D",
+"a  c #C17E7E",
+"$. c #877300",
+"@. c #7A6100",
+"u  c #AB747C",
+"r  c #817141",
+"t  c #908050",
+"#  c #D51E1E",
+"_  c #FFE86E",
+"Z  c #5A4F07",
+"(  c #FFF18D",
+"O. c #FFE56B",
+"4  c #FEFFFA",
+"3. c #968E54",
+"Q  c #A79A6D",
+"L  c #C0A862",
+"M  c #E6D176",
+"j  c #5C4C30",
+"=  c #F9120F",
+"0  c #FD0000",
+"+. c #F6DE5B",
+"W  c #F8EA98",
+"!  c #7D7459",
+"I  c #F0D993",
+"&  c #C07F7F",
+"+  c #D7D7D7",
+"V  c #7E6912",
+"5  c #FFFDFE",
+"C  c #9F9445",
+"e  c #BAAE7A",
+">. c #FBF7CE",
+"N  c #958024",
+")  c #FFFF93",
+"z  c #F70303",
+"$  c #F70305",
+";. c #AEA976",
+"`  c #FFFF9F",
+"O  c #C9C9C9",
+",  c #C17D7E",
+"A  c #524300",
+"X  c #E7E7E7",
+"X. c #FFFFB1",
+"b  c #FFFFB7",
+"S  c #786C1E",
+"P  c #FFFCB4",
+"-. c #A29B72",
+".. c #FFFFC2",
+"x  c #DEDAB5",
+"2. c #8C854B",
+"3  c #F80403",
+"Y  c #FFF9B7",
+"m  c #FFFFCD",
+"|  c #DED7BB",
+"i  c #EF0C0F",
+":. c #FFFFDA",
+"K  c #FFFFDB",
+/* pixels */
+"                  . X o O o X . ",
+"                . + @ # $ % & + ",
+"                X * = - ; : > , ",
+"                o < 1 - 1 - 2 # ",
+"                O 3 : 4 5 6 7 8 ",
+"                o < 9 2 1 0 q w ",
+"    e r t y     X u i 0 - - p a ",
+"  s d f g h j   . + k l z < @ + ",
+"x c v b n m M N B V C Z A S D . ",
+"F G H J K L P I U Y T R E W Q   ",
+"! ~ ^ / ( ) _ ` ' ) ] ) [ { }   ",
+"|  ...X.o.O.+.@.#.$.%.&.*.=.    ",
+"  -.;.:.>.,.<.                  ",
+"    1.2.3.                      ",
+"                                ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/pk_present_sm.xpm b/pgadmin/include/images/sv/pk_present_sm.xpm
new file mode 100644
index 0000000..44b6142
--- /dev/null
+++ b/pgadmin/include/images/sv/pk_present_sm.xpm
@@ -0,0 +1,137 @@
+/* XPM */
+static const char *pk_present_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 115 2",
+"E  c #FFF3B5",
+"g  c #FFFFE0",
+"w  c #0A7A00",
+"W  c #FFFFE6",
+"|  c #B9A058",
+"Y  c #FFFFEE",
+"(  c #80650D",
+"[  c #C0B52D",
+"f  c #FFFFF1",
+":  c #087A00",
+"$  c #087A01",
+"$. c #D9C633",
+"6  c #FFFFFD",
+"^  c #FFFFFE",
+"O. c #FBE47B",
+"4  c #FFFFFF",
+"H  c #97946E",
+"0  c #1A6A13",
+"<. c #BFBA91",
+"G  c #BFAE76",
+"C  c #685200",
+"z  c #186A12",
+"b  c #C9BC8D",
+"-  c #186A13",
+"&  c #1C8414",
+"*. c #786B00",
+"R  c #F4E9AC",
+"%  c #097B01",
+"7  c #097B02",
+"k  c #454545",
+"o  c #157D0B",
+"i  c #315B42",
+"u  c #BDAB78",
+"O  c #4D9F48",
+"+  c #BFDDBD",
+"   c None",
+"1. c #6B654C",
+"s  c #665B37",
+"h  c #DBCCAA",
+"A  c #504B23",
+"#  c #188110",
+"&. c #EADD43",
+"/  c #EDD996",
+"}  c #AF973B",
+"S  c #1E1A02",
+"n  c #FFF2B3",
+"{  c #F1DE63",
+"Z  c #5D4E0D",
+"-. c #BC9D2D",
+"<  c #0A7901",
+"D  c #302700",
+";  c #087C00",
+">  c #FFFEFF",
+"2. c #CEC588",
+"K  c #604C09",
+"M  c #ECD47A",
+"F  c #685D1A",
+"=  c #B7B7B7",
+"8  c #127E0D",
+"J  c #EEDDB1",
+"=. c #A59103",
+"d  c #D8D0A7",
+"9  c #474747",
+",  c #0B7A01",
+"q  c #0B7A02",
+".. c #C4B482",
+"]  c #AA9511",
+"%. c #877300",
+"#. c #7A6100",
+"t  c #817141",
+"y  c #908050",
+".  c #C1DCBD",
+"`  c #FFE86E",
+")  c #FFF18D",
+"+. c #FFE56B",
+"4. c #968E54",
+"!  c #A79A6D",
+"P  c #C0A862",
+"B  c #E6D176",
+"2  c #757575",
+"@  c #90AF8F",
+"j  c #5C4C30",
+"*  c #BDDCBC",
+"5  c #FCFFFF",
+"@. c #F6DE5B",
+"Q  c #F8EA98",
+"~  c #7D7459",
+"a  c #1B810E",
+"U  c #F0D993",
+"1  c #4E9F47",
+"c  c #93B091",
+"l  c #466243",
+"3  c #0D7903",
+"r  c #BAAE7A",
+",. c #FBF7CE",
+"V  c #958024",
+"_  c #FFFF93",
+":. c #AEA976",
+"'  c #FFFF9F",
+"p  c #0B7C10",
+"o. c #FFFFB1",
+"e  c #4DA047",
+"m  c #FFFFB7",
+"X  c #4DA048",
+"I  c #FFFCB4",
+";. c #A29B72",
+"X. c #FFFFC2",
+"v  c #DEDAB5",
+"3. c #8C854B",
+"T  c #FFF9B7",
+"N  c #FFFFCD",
+"x  c #0C7A04",
+" . c #DED7BB",
+">. c #FFFFDA",
+"L  c #FFFFDB",
+/* pixels */
+"                                ",
+"                    . X o O +   ",
+"                  @ # $ % % & * ",
+"                = - ; : > , < 1 ",
+"                2 3 < 4 5 6 7 8 ",
+"                9 0 q w 6 , $ e ",
+"    r t y u     2 i p % < % a * ",
+"  s d f g h j   = k l z x 0 c   ",
+"v b n m M N B V C Z A S D F G   ",
+"H J 6 K L P I U Y T R E W Q !   ",
+"~ ^ / ( ) _ ` ' ] _ [ _ { } |   ",
+" ...X.o.O.+.@.#.$.%.&.*.=.-.    ",
+"  ;.:.>.,.<.1.                  ",
+"    2.3.4.                      ",
+"                                ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/red.xpm b/pgadmin/include/images/sv/red.xpm
new file mode 100644
index 0000000..65aa09c
--- /dev/null
+++ b/pgadmin/include/images/sv/red.xpm
@@ -0,0 +1,29 @@
+/* XPM */
+static const char *red_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"15 13 10 1",
+"o c #D07F7C",
+"X c #D07F7E",
+"O c #D1807C",
+"# c #D1807D",
+"@ c #D1807F",
+"  c #CF7D7F",
+". c #D07E80",
+"% c #D07E82",
+"+ c #D17F81",
+"$ c #D0807F",
+/* pixels */
+" .XXoXXXXXO.X++",
+".+@@@@@@@X#.X++",
+"X@@@@@@@@.#.X@@",
+"X@@@@@@@@+#+@@@",
+"X@@@@@@@@+@+@@@",
+"X@@@@@@@@+@.X@@",
+"X@@@@@@@@+@.X#@",
+"X@@@@@@@@.@+X#@",
+"X@@@@@@@@+++X$$",
+"X@@@@@@@@+@+o@#",
+"X@@@@@@@@@@+X@@",
+"X@@@@@@@@o%#.o.",
+"X@@@@@@@@o%#.o."
+};
diff --git a/pgadmin/include/images/sv/rule_changed_sm.xpm b/pgadmin/include/images/sv/rule_changed_sm.xpm
new file mode 100644
index 0000000..7100335
--- /dev/null
+++ b/pgadmin/include/images/sv/rule_changed_sm.xpm
@@ -0,0 +1,97 @@
+/* XPM */
+static const char *rule_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 75 1",
+"A c #695D33",
+"3 c #696969",
+"M c #FFE492",
+"H c #FFE494",
+"y c #FFE495",
+"h c #FFE497",
+"X c #828FB4",
+"z c #4E401A",
+"l c #B29F60",
+"1 c #FFFFFF",
+"e c #122559",
+"; c #5D6A8F",
+", c #9E9E9E",
+"G c #E2C76A",
+"q c #5B460C",
+"c c #15295B",
+"s c #0B2467",
+"6 c #132656",
+"L c #FEE286",
+"V c #FEE287",
+"r c #182A5A",
+"% c #09246B",
+"K c #FEE289",
+"  c None",
+"5 c #3E2F08",
+"d c #1B2E5E",
+"8 c #0C2568",
+"o c #3E538B",
+"D c #695C31",
+"- c #E3E3E3",
+"& c #0F296E",
+"B c #FFE38B",
+"J c #FFE38D",
+"N c #FFE38F",
+"j c #FFE390",
+"S c #473E22",
+"p c #24282F",
+"C c #E2C976",
+"f c #564D35",
+"a c #15285B",
+"I c #FEE17F",
+"P c #FEE182",
+"n c #A98526",
+"> c #314680",
+"+ c #C2C6D1",
+"k c #E3CA7E",
+"= c #9DA7C4",
+"m c #FFE598",
+"0 c #FFE599",
+"t c #FFE59A",
+"g c #FFE59B",
+"R c #EBCC7A",
+"9 c #FFE59C",
+"< c #1C3169",
+". c #DADEE9",
+"7 c #0B2567",
+"v c #1A2B57",
+": c #1A316B",
+"4 c #DDA91D",
+"2 c #10296D",
+"T c #FEE077",
+"Y c #FEE079",
+"U c #FEE07C",
+"x c #273148",
+"i c #544F3E",
+"w c #27314B",
+"O c #132D71",
+"* c #364C84",
+"# c #1D326B",
+"@ c #636D8A",
+"F c #9D8B4A",
+"b c #5C6060",
+"Z c #9D8B50",
+"u c #896912",
+"$ c #0C266A",
+/* pixels */
+"                ",
+"        .XoOoX. ",
+"       +@#$%&*=.",
+"      -;:%%%%%>X",
+"      ,<$%%11%2o",
+"      3$%%1%%%%O",
+" 44444567%1%%%8o",
+"494940qwe%%11%rX",
+"494t4yuipas%sdf.",
+"4g0h4jklzxc8vbn ",
+"4myMNBVCZASDFG4 ",
+"4HjJKLPIUYTTTT4 ",
+"R4444444444444  ",
+"                ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/rule_missing_sm.xpm b/pgadmin/include/images/sv/rule_missing_sm.xpm
new file mode 100644
index 0000000..b1b2991
--- /dev/null
+++ b/pgadmin/include/images/sv/rule_missing_sm.xpm
@@ -0,0 +1,99 @@
+/* XPM */
+static const char *rule_missing_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 77 1",
+"B c #D2BA69",
+"A c #FFE492",
+"I c #FFE494",
+"g c #FFE495",
+"v c #FFE497",
+"l c #CF1403",
+"6 c #FFFFFF",
+"% c #D41E1F",
+"w c #FE0300",
+"- c #FE0000",
+"7 c #FE0002",
+": c #FE0003",
+"t c #D2180E",
+"> c #FA0F0F",
+"@ c #C17F7F",
+"o c #D3D3D3",
+"G c #FEE284",
+"U c #FEE286",
+"F c #FEE287",
+"m c #FEE289",
+"h c #F9DE8C",
+"  c None",
+"r c #FF0100",
+"2 c #FF0101",
+"1 c #FF0103",
+". c #F9F9F9",
+"k c #A76950",
+"a c #EF0B0E",
+"V c #C8B162",
+"8 c #F60304",
+"N c #E6CC76",
+"D c #FFE38B",
+"n c #FFE38D",
+"S c #FFE38F",
+"b c #FFE390",
+"< c #D41D1D",
+"p c #9E5326",
+"; c #FE0200",
+"j c #BA8E18",
+"* c #C17E7D",
+"J c #FEE17D",
+"T c #FEE17F",
+"H c #FEE181",
+"Y c #FEE182",
+"# c #D51E1E",
+"4 c #FEFFFA",
+"C c #E6CB6C",
+"= c #F9120F",
+"e c #FD0000",
+"s c #F90F11",
+"x c #C0734D",
+"Z c #FFE598",
+"u c #FFE599",
+"f c #FFE59A",
+"c c #FFE59B",
+"W c #EBCC7A",
+"y c #FFE59C",
+"& c #C07F7F",
+"+ c #D7D7D7",
+"0 c #B78C18",
+"5 c #FFFDFE",
+"d c #B45C28",
+"z c #F70302",
+"$ c #F70305",
+"M c #D8A51C",
+"9 c #DDA91D",
+"i c #E7CF86",
+"P c #FEE077",
+"L c #FEE078",
+"E c #FEE079",
+"O c #C9C9C9",
+"K c #FEE07B",
+"R c #FEE07C",
+", c #C17D7E",
+"X c #E7E7E7",
+"q c #D01303",
+"3 c #F80403",
+/* pixels */
+"                ",
+"        .XoOoX. ",
+"       .+@#$%&+.",
+"       X*=-;:>,X",
+"       o<1-1-2#o",
+"       O3:45678O",
+" 9999990qw21erto",
+"9y9y9u9ipae--sdX",
+"9y9f9g9hjklzqxj.",
+"9cuv9bnmMNBV0CM ",
+"9ZgASDFGHJKLPP9 ",
+"9IbnmUYTREPPPP9 ",
+"W9999999999999  ",
+"                ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/rule_present_sm.xpm b/pgadmin/include/images/sv/rule_present_sm.xpm
new file mode 100644
index 0000000..914d7be
--- /dev/null
+++ b/pgadmin/include/images/sv/rule_present_sm.xpm
@@ -0,0 +1,98 @@
+/* XPM */
+static const char *rule_present_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 76 1",
+"e c #0A7A00",
+"A c #FFE492",
+"a c #1B800C",
+"P c #FFE494",
+"f c #FFE495",
+"v c #FFE497",
+": c #087A00",
+"$ c #087A01",
+"6 c #FFFFFD",
+"4 c #FFFFFF",
+"j c #465E30",
+"g c #B7A367",
+"B c #473F23",
+"- c #186A13",
+"& c #1C8414",
+"z c #186402",
+"l c #0B7802",
+"p c #0B7B0F",
+"% c #097B01",
+"7 c #097B02",
+"G c #FEE284",
+"I c #FEE286",
+"F c #FEE287",
+"o c #157D0B",
+"m c #FEE289",
+"r c #489222",
+"O c #4D9F48",
+"+ c #BFDDBD",
+"V c #756739",
+"  c None",
+"0 c #3E2F08",
+"N c #75673C",
+"# c #188110",
+"D c #FFE38B",
+"< c #0A7901",
+"n c #FFE38D",
+"S c #FFE38F",
+"b c #FFE390",
+"; c #087C00",
+"> c #FFFEFF",
+"= c #B7B7B7",
+"8 c #127E0D",
+", c #0B7A01",
+"w c #0B7A02",
+"J c #FEE17D",
+"Y c #FEE17F",
+"H c #FEE181",
+"U c #FEE182",
+". c #C1DCBD",
+"i c #2C4D1E",
+"u c #756944",
+"2 c #757575",
+"@ c #90AF8F",
+"* c #BDDCBC",
+"5 c #FCFFFF",
+"h c #3C2E08",
+"q c #176403",
+"Z c #FFE598",
+"y c #FFE599",
+"1 c #4E9F47",
+"d c #FFE59A",
+"c c #FFE59B",
+"E c #EBCC7A",
+"t c #FFE59C",
+"k c #156402",
+"3 c #0D7903",
+"9 c #DDA91D",
+"s c #A8A62F",
+"C c #FEE077",
+"L c #FEE078",
+"R c #FEE079",
+"K c #FEE07B",
+"T c #FEE07C",
+"M c #9F7915",
+"x c #92A256",
+"X c #4DA048",
+/* pixels */
+"                ",
+"                ",
+"         .XoO+  ",
+"        @#$%%&* ",
+"       =-;:>,<1 ",
+"       23<45678 ",
+" 9999990qwe6,$r ",
+"9t9t9y9uip%<%as ",
+"9t9d9f9ghjklzx9 ",
+"9cyv9bnmMNBVMC9 ",
+"9ZfASDFGHJKLCC9 ",
+"9PbnmIUYTRCCCC9 ",
+"E9999999999999  ",
+"                ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/rules_changed_sm.xpm b/pgadmin/include/images/sv/rules_changed_sm.xpm
new file mode 100644
index 0000000..f192f1b
--- /dev/null
+++ b/pgadmin/include/images/sv/rules_changed_sm.xpm
@@ -0,0 +1,183 @@
+/* XPM */
+static const char *rules_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 161 2",
+"S. c #C4AC26",
+"j  c #E4FDFF",
+"{  c #6E6135",
+"*. c #FFE486",
+"<. c #13185A",
+"f  c #37415C",
+"S  c #1D2063",
+",. c #142559",
+"q  c #EEFFFF",
+"L  c #FAE39F",
+"B. c #FFDE83",
+"d  c #FFDE88",
+"s. c #FFDE8A",
+"Q  c #F3FDF5",
+"h  c #062963",
+"$. c #CEA81F",
+"4. c #D6B00F",
+"U  c #FFDE91",
+"6. c #DAAA2C",
+"y. c #A09716",
+"q. c #243B64",
+"t  c #38424C",
+"L. c #FAE6C5",
+"I  c #FFDB96",
+"b  c #DDAB16",
+"`  c #CDB81D",
+" . c #062671",
+"u  c #D8AA23",
+".. c #022952",
+"]  c #E2BE4E",
+"E  c #0D2474",
+"&  c #7E95CB",
+"T  c #2C436F",
+"p  c #D8A72E",
+"5. c #FFCF88",
+"x. c #CDB838",
+"a  c #FFEC6A",
+"5  c #D4AA16",
+"G  c #042073",
+"n. c #FFE35F",
+"2  c #D4B03E",
+"~  c #072466",
+"   c None",
+"2. c #6E6F4D",
+"J. c #CDA61B",
+"0  c #132672",
+"l. c #FFDA51",
+"7  c #756A4A",
+"t. c #957C53",
+"N. c #FFEC92",
+"k. c #E0AF49",
+"P  c #E3AA1B",
+"Z. c #CABC15",
+"<  c #E5E0E6",
+"a. c #FFE991",
+"e. c #28344A",
+">. c #0C1C5A",
+"9  c #00206B",
+"y  c #A49DAD",
+"N  c #CEB01E",
+"v  c #6E6F69",
+"C  c #051B55",
+"-. c #8B7D8C",
+"m  c #DAA90F",
+"9. c #DFC86B",
+"C. c #D7B762",
+"|  c #05247E",
+"}  c #312C64",
+"F  c #051E6E",
+"(  c #64677A",
+"z  c #0F2676",
+"O  c #141E51",
+"H. c #C9A31C",
+"B  c #D0A429",
+"Z  c #06255B",
+",  c #9698AD",
+"3. c #E8DEE7",
+"v. c #FFD77E",
+"!  c #F1FFFA",
+"K  c #DFA71C",
+"H  c #19256D",
+"g. c #FFDA95",
+":  c #213069",
+"b. c #FFDA98",
+";  c #19226D",
+"M. c #EDE485",
+"=. c #AFA83E",
+"1. c #474A5B",
+"G. c #D7B613",
+"O. c #07234A",
+"[  c #C8B02A",
+"X  c #6F7CA6",
+"z. c #D0BE2C",
+"k  c #182649",
+"l  c #101E5D",
+"w  c #EDFFFF",
+"h. c #FEE7A3",
+"p. c #D2AC19",
+"&. c #DCB41E",
+"r  c #132565",
+"4  c #CDA512",
+"V  c #253863",
+"g  c #18235B",
+";. c #2C3361",
+"A  c #EBFFFF",
+"u. c #E5C789",
+">  c #3E4C71",
+"8. c #C5BA13",
+"A. c #D2B245",
+"s  c #D0B230",
+"m. c #F5E08D",
+"j. c #F3DA64",
+"o  c #37455F",
+".  c #DEE1E6",
+"c  c #162051",
+":. c #182069",
+"#. c #C0B012",
+"@. c #A3A37F",
+"6  c #D4A030",
+"'  c #FFE595",
+"W  c #16205D",
+"w. c #0A2165",
+"#  c #878EA0",
+"c. c #FFDC7E",
+"f. c #DFAF1D",
+"r. c #362643",
+"_  c #FFDF88",
+"^  c #082A74",
+"+  c #202867",
+"e  c #0A1E63",
+"/  c #152D47",
+"V. c #FFCD50",
+")  c #D6B10A",
+"D  c #151987",
+"n  c #FDE899",
+"x  c #0F2578",
+"d. c #FFDC8B",
+"*  c #2B4381",
+"%. c #FFDC92",
+"J  c #474C45",
+"Y  c #DFAF33",
+"7. c #FFDC98",
+"M  c #CAAF20",
+"R  c #102C6B",
+"8  c #3B275A",
+"D. c #E39A29",
+"@  c #384361",
+"i  c #FEE990",
+"%  c #C5DEE3",
+"0. c #476333",
+"=  c #152769",
+"F. c #DDA628",
+"o. c #092B84",
+"1  c #FFC16D",
+"X. c #022778",
+"3  c #E0A722",
+"+. c #2F3646",
+"$  c #E0E0EA",
+"i. c #D2AB2C",
+"K. c #DABC3A",
+"-  c #0E1A64",
+/* pixels */
+"                                ",
+"                                ",
+"              . X o O + @ # $   ",
+"            % & * = - ; : > , < ",
+"1 2 3 4 5 6 7 8 9 0 q w e r t y ",
+"u i p a s d f g h j k l z x c v ",
+"b n m M N B V C Z A S D F G H J ",
+"K L P I U Y T R E W Q ! ~ ^ / ( ",
+") _ ` ' ] [ { } |  ...X.o.O.+.@.",
+"  #.$.%.&.*.=.-.;.:.>.,.<.1.2.3.",
+"    4.5.6.7.8.9.0.q.w.e.r.t.y.  ",
+"    u.i.p.a.s.d.f.g.h.j.k.l.z.  ",
+"        x.c.v.b.n.m.M.N.B.V.C.  ",
+"          Z.A.S.D.F.G.H.J.K.L.  ",
+"                                ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/schema_changed_sm.xpm b/pgadmin/include/images/sv/schema_changed_sm.xpm
new file mode 100644
index 0000000..f9151dc
--- /dev/null
+++ b/pgadmin/include/images/sv/schema_changed_sm.xpm
@@ -0,0 +1,105 @@
+/* XPM */
+static const char *schema_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 83 1",
+"^ c #D69496",
+"& c #283E78",
+"+ c #8C97B3",
+"A c #692E2E",
+"d c #642D37",
+"X c #828FB4",
+"4 c #D99592",
+"< c #D99594",
+"c c #FFFFFD",
+"I c #D99596",
+": c #FFFFFF",
+"> c #0D276B",
+", c #293F76",
+"/ c #BC494C",
+"W c #D79295",
+"8 c #0B2468",
+"h c #0B2469",
+"i c #384569",
+"n c #38456A",
+"* c #7481A6",
+"$ c #09246B",
+"z c #FF7775",
+"m c #9A9EA8",
+"R c #FC615D",
+"  c None",
+"H c #BD4A47",
+"S c #351413",
+"G c #D89396",
+"; c #0C2569",
+"o c #3E538B",
+"g c #112059",
+"C c #E3E3E1",
+"M c #E3E3E3",
+"j c #142A62",
+"u c #142A65",
+"@ c #283D76",
+"% c #7382A6",
+"Y c #FF5F61",
+"s c #FE7E7F",
+"! c #FF5C5D",
+"D c #593D3E",
+"3 c #0D266A",
+"0 c #172B63",
+"w c #BE4848",
+"7 c #122158",
+"6 c #FF888A",
+"r c #BC4848",
+"P c #BC4849",
+"E c #C1494A",
+"Z c #742D2D",
+"V c #FEFFFF",
+"f c #3E4965",
+"5 c #BD4949",
+"a c #BD494A",
+"F c #9D9E9E",
+"Q c #D69591",
+"U c #D69593",
+"J c #FF6769",
+"x c #BB4948",
+"v c #AA4042",
+"k c #878B96",
+"( c #D99391",
+"= c #D99393",
+"q c #D99395",
+"2 c #0D2569",
+"l c #BE4749",
+"N c #D79694",
+". c #DADEE9",
+"1 c #BC4A4A",
+"~ c #D79394",
+"9 c #0B2569",
+"e c #FF8484",
+"t c #38466A",
+"L c #FE6869",
+"- c #21265D",
+"O c #132D71",
+"K c #BF484A",
+"T c #BF484C",
+"B c #FF6F6E",
+"p c #D89495",
+"# c #0C266B",
+"b c #72323C",
+"y c #11215B",
+/* pixels */
+"       .XoOoX.  ",
+"      .+@#$#@+. ",
+"      %&$$$$$&* ",
+"     =-;$$::$>, ",
+"    <12$$:$$$$3 ",
+"   45678$:$$$90 ",
+"  qwerty$$::$ui ",
+" pasr:dfg8$hjfk ",
+" lzxcrvbi787nmM ",
+" NwBaVaCZASDFM  ",
+"  GHJKVaLPI     ",
+"   UaYTREW      ",
+"    QH!H~       ",
+"     ^/(        ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/schema_missing_sm.xpm b/pgadmin/include/images/sv/schema_missing_sm.xpm
new file mode 100644
index 0000000..fcd29d3
--- /dev/null
+++ b/pgadmin/include/images/sv/schema_missing_sm.xpm
@@ -0,0 +1,137 @@
+/* XPM */
+static const char *schema_missing_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 115 2",
+"j  c #AD5251",
+".  c #CC8374",
+"_  c #FFFFE1",
+"0  c #FFFFE4",
+"@  c #C77F80",
+"o. c #FDFFD8",
+"|  c #C69B94",
+"e  c #EF0000",
+"K  c #C4D9D0",
+"%. c #D6535B",
+"]  c #C15958",
+"^  c #DCA2A1",
+"}  c #D79B9D",
+">. c #A44B47",
+"$. c #DB8689",
+"g  c #DB1C2C",
+"6  c #C0664E",
+":  c #C00510",
+"A  c #AB4C64",
+"F  c #D10B18",
+"I  c #A05144",
+"7  c #EE0D15",
+"4  c #D5989F",
+"R  c #A94C5F",
+"U  c #F7FFD8",
+"H  c #E50C03",
+"=. c #F45961",
+"/  c #A24244",
+"w  c #FF0707",
+"O. c #BD5053",
+"1. c #C5968E",
+"3. c #994A4D",
+"n  c #FA0008",
+"   c None",
+"s  c #FF0410",
+"P  c #FF7484",
+"<  c #F80000",
+"b  c #F80004",
+"2  c #FA0019",
+"+  c #CE8282",
+"m  c #E41C1E",
+"9  c #F3F3BF",
+".. c #FC5B6B",
+"E  c #FBD8C2",
+"%  c #F40000",
+"p  c #F40006",
+"J  c #C37E6F",
+"@. c #C34F58",
+"8  c #EC180D",
+"f  c #E60108",
+"k  c #FF8589",
+"#. c #D59A9C",
+"(  c #EE7C7C",
+"S  c #E1D4DE",
+"2. c #E8979E",
+"V  c #FF7F82",
+"#  c #EA1200",
+"<. c #C14648",
+"`  c #B1565B",
+"!  c #9D4048",
+"Y  c #BA4850",
+"&  c #FF0911",
+"d  c #FF060F",
+";  c #91614A",
+"a  c #FF0613",
+"h  c #E88894",
+"$  c #F60500",
+"Z  c #FAFFE4",
+"v  c #FF000E",
+"l  c #BD464C",
+"&. c #EE6169",
+">  c #FF0019",
+"{  c #A84C51",
+"O  c #E1111E",
+"T  c #B84258",
+"+. c #F75668",
+"W  c #95463F",
+"L  c #B44B52",
+"-  c #D68F93",
+"*  c #EA0315",
+":. c #D68C8B",
+"G  c #FB0000",
+"q  c #FFF1C6",
+"B  c #A2584F",
+"x  c #882B33",
+"r  c #CB9A9D",
+"=  c #BF8C79",
+"C  c #B74642",
+"N  c #D7969A",
+"X  c #E01B24",
+",. c #FF5873",
+"'  c #FFF1EC",
+"u  c #A24331",
+"y  c #FF848D",
+"c  c #F50913",
+"~  c #FCDBD6",
+"5  c #C84650",
+"*. c #BD544E",
+"D  c #893243",
+"1  c #FF0E14",
+"i  c #C41A1B",
+"M  c #C98572",
+"[  c #DB7276",
+"t  c #C84356",
+"3  c #E71339",
+"-. c #D24B59",
+"4. c #D69D96",
+"o  c #EC050B",
+"z  c #FFD9CD",
+",  c #FF0511",
+" . c #E04157",
+"Q  c #CC5A62",
+")  c #D93D4A",
+";. c #DA858A",
+"X. c #BB4B49",
+/* pixels */
+"                                ",
+"                . X o O +       ",
+"              @ # $ % & * =     ",
+"          - ; : > , < 1 2 3     ",
+"        4 5 6 7 8 9 0 q w e     ",
+"      r t y u i p a s d f g     ",
+"    h j k l z x c v b n m M     ",
+"  N B V C Z A S D F G H J K     ",
+"  L P I U Y T R E W Q ! ~       ",
+"  ^ / ( ) _ ` ' ] [ { }         ",
+"    |  ...X.o.O.+.@.#.          ",
+"      $.%.&.*.=.-.;.            ",
+"        :.>.,.<.1.              ",
+"          2.3.4.                ",
+"                                ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/schema_present_sm.xpm b/pgadmin/include/images/sv/schema_present_sm.xpm
new file mode 100644
index 0000000..50a6e53
--- /dev/null
+++ b/pgadmin/include/images/sv/schema_present_sm.xpm
@@ -0,0 +1,137 @@
+/* XPM */
+static const char *schema_present_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 115 2",
+"X. c #B44D48",
+"P  c #FF6F82",
+"_  c #FFFFE1",
+"z  c #FFFFE6",
+"c  c #0E7114",
+"b  c #017F00",
+">  c #147C00",
+"+. c #F5586D",
+")  c #D53D49",
+"9  c #FFFCF6",
+",  c #236525",
+"x  c #493C29",
+"A  c #965865",
+"-. c #BC525E",
+"e  c #1D7113",
+" . c #E64058",
+"g  c #1D7119",
+"=. c #F85661",
+"E  c #BAB08C",
+"a  c #1B7720",
+"n  c #14730B",
+"L  c #B0474E",
+"/  c #AB4046",
+"4. c #DA9995",
+"+  c #A6CFB1",
+"D  c #3C4A30",
+"k  c #F68887",
+"{  c #A74C55",
+"%  c #077E00",
+"w  c #008000",
+"I  c #A34F44",
+":. c #D38F8C",
+"   c None",
+"Q  c #541311",
+"y  c #F28B86",
+"F  c #14640B",
+"]  c #C55B5B",
+"~  c #B5A3A3",
+"j  c #B64C50",
+"B  c #AD5450",
+"S  c #B6B9BE",
+"h  c #E18590",
+"*. c #BE5750",
+"`  c #AD5458",
+"u  c #B05844",
+"8  c #087F00",
+"l  c #B64348",
+"!  c #5F282D",
+"2  c #18750A",
+">. c #9F4F48",
+"H  c #076C02",
+"f  c #0A7910",
+";. c #D99799",
+"@. c #CC4D5E",
+"T  c #BB475C",
+"Z  c #FFF8E6",
+"N  c #EE8E9C",
+";  c #AC5E51",
+"O. c #BE4B50",
+"^  c #E1A5A5",
+"6  c #FF8579",
+"v  c #186C0E",
+",. c #FF5973",
+"}  c #D0999F",
+"o. c #F9FED6",
+"G  c #0B7A02",
+"s  c #EDFFE3",
+"|  c #CE9995",
+"o  c #337722",
+"'  c #FFECE9",
+"3  c #478425",
+"-  c #E38D96",
+"&. c #EB666B",
+"$. c #DE8388",
+"t  c #BF4F5B",
+"[  c #D66C70",
+"1  c #10750D",
+"*  c #1F841A",
+"#. c #E99EA5",
+"%. c #D3565C",
+"J  c #486B41",
+"2. c #E29A9E",
+"<. c #C44146",
+"q  c #E7FFE5",
+"C  c #C74B4B",
+"O  c #51AC4C",
+"(  c #F27B7D",
+"W  c #59301C",
+"M  c #58846D",
+".. c #F85D6B",
+"U  c #F4FFD8",
+"<  c #FFFAFF",
+"#  c #0A9506",
+"=  c #B4D8CA",
+"m  c #1B781D",
+"$  c #186809",
+"d  c #0B7C08",
+"i  c #2A550E",
+"3. c #964A4C",
+"7  c #207615",
+"r  c #DE8E9B",
+"K  c #BAB7AE",
+"R  c #B54F65",
+"5  c #B85051",
+"@  c #BFE1BE",
+":  c #276E22",
+"4  c #CE8F97",
+"0  c #F2FFFF",
+"X  c #44A242",
+"V  c #FF7278",
+"&  c #176F0B",
+"Y  c #B64D52",
+".  c #A4EAA4",
+"1. c #BC9993",
+"p  c #037F00",
+/* pixels */
+"                                ",
+"                . X o O +       ",
+"              @ # $ % & * =     ",
+"          - ; : > , < 1 2 3     ",
+"        4 5 6 7 8 9 0 q w e     ",
+"      r t y u i p a s d f g     ",
+"    h j k l z x c v b n m M     ",
+"  N B V C Z A S D F G H J K     ",
+"  L P I U Y T R E W Q ! ~       ",
+"  ^ / ( ) _ ` ' ] [ { }         ",
+"    |  ...X.o.O.+.@.#.          ",
+"      $.%.&.*.=.-.;.            ",
+"        :.>.,.<.1.              ",
+"          2.3.4.                ",
+"                                ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/schemas_changed_sm.xpm b/pgadmin/include/images/sv/schemas_changed_sm.xpm
new file mode 100644
index 0000000..6da6b9b
--- /dev/null
+++ b/pgadmin/include/images/sv/schemas_changed_sm.xpm
@@ -0,0 +1,228 @@
+/* XPM */
+static const char *schemas_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 206 2",
+"C. c #FFFFDD",
+"X  c #D74049",
+")  c #152F40",
+" X c #B44740",
+"e. c #7383A7",
+"~  c #EEFFFD",
+"T  c #C94457",
+"7  c #D5AAA4",
+"@X c #FF636E",
+"^. c #C0494D",
+"w  c #102E54",
+"B. c #FB7279",
+"a. c #C63447",
+"c  c #151881",
+"i  c #16226C",
+"z. c #C04C59",
+"F. c #FD6363",
+"M  c #D29793",
+"@. c #1B1D5A",
+"). c #E794A6",
+"(. c #B13A4D",
+"Q. c #C74454",
+"W. c #FFF6E4",
+"=  c #DE999C",
+"OX c #D79EA5",
+"-. c #AB463E",
+"}  c #FF92A2",
+"'. c #FF5D75",
+"]. c #B04A45",
+"6  c #EBE6ED",
+"<. c #062365",
+"p  c #494B60",
+"u  c #122260",
+"$  c #1A3061",
+"K. c #F96F7C",
+"@  c #243E7B",
+"$. c #A98DA4",
+"D  c #0E2B65",
+"r. c #2F215C",
+":X c #CD4C50",
+"H  c #002F64",
+"g  c #C84B5B",
+"3X c #C29288",
+"J  c #002F69",
+"R  c #BB395D",
+"e  c #062077",
+"oX c #EB9C97",
+"G. c #C84243",
+"&  c #8D92A8",
+"h  c #F9FFF4",
+"B  c #FF7A7C",
+"!. c #D44149",
+"l. c #FA706E",
+"q  c #964C6D",
+"^  c #E6FFFA",
+"m. c #AF4E3D",
+"$X c #F0656C",
+"8. c #F6828B",
+"   c None",
+"O  c #DBDEE5",
+"{  c #B8494F",
+"|. c #C4484A",
+"!  c #132064",
+"_. c #D38C90",
+"9. c #BD4A57",
+",X c #D3545D",
+"g. c #B6494C",
+"#  c #0F2962",
+"I. c #E9908C",
+"6. c #D88D94",
+"t  c #F5FFFA",
+"3  c #22296F",
+">. c #1E2F63",
+";X c #DD8B91",
+"H. c #FFF8DF",
+"n  c #1B256C",
+"b. c #B6404C",
+"o  c #D49091",
+"A  c #152E56",
+"E  c #4C315E",
+";  c #FF8E92",
+"]  c #F97175",
+"N  c #BA5752",
+"%X c #C54651",
+"k. c #BC4E4F",
+"G  c #0C1981",
+"v  c #092C64",
+"M. c #E69A82",
+"y. c #251B50",
+"X. c #122470",
+"h. c #FFECE0",
+"1. c #10245F",
+"-  c #B0464A",
+"8  c #C03C51",
+"o. c #10276D",
+"d  c #B23D45",
+"[  c #A94543",
+"0  c #B74453",
+"5  c #9492AA",
+"f. c #FF828C",
+"&. c #994F46",
+"V. c #BC3F3D",
+"f  c #E88E8E",
+"p. c #E2747F",
+"#X c #C64442",
+"v. c #F9FBF0",
+"P. c #D58B8A",
+"/  c #002864",
+"s  c #DA9295",
+"m  c #68635F",
+"L. c #CF3C4C",
+",. c #0E246D",
+"Z. c #BB585B",
+"`. c #CD4559",
+"b  c #002563",
+"0. c #B3444B",
+"(  c #052C71",
+"A. c #DE7D86",
+"I  c #FF7076",
+",  c #253E7E",
+"+. c #0E1E69",
+"S  c #00287A",
+":  c #9E4D5C",
+"V  c #BD464C",
+"T. c #B44E4A",
+"%. c #D49890",
+"&X c #CD9D99",
+"Y. c #FD7078",
+"Q  c #0E1E7D",
+"x. c #FCF6EA",
+"U  c #B4453A",
+"d. c #C74B56",
+"F  c #1D1E61",
+"O. c #0A2167",
+"{. c #BE5051",
+" . c #2C2457",
+"#. c #3B2D51",
+"Y  c #FFF7DD",
+"C  c #FFFAE7",
+"x  c #221F62",
+">X c #E25357",
+"R. c #FFF4D9",
+"1  c #142364",
+"E. c #AE5A58",
+"w. c #945029",
+"3. c #472C57",
+"U. c #C5484E",
+"t. c #042A5B",
+"`  c #E08E90",
+"*  c #DDE8DA",
+";. c #A84355",
+"<X c #D48C8F",
+"k  c #06276C",
+"a  c #A797A2",
+"+X c #D53B55",
+"1X c #D09283",
+"s. c #C29C93",
+"c. c #9D5468",
+"}. c #F66375",
+"=. c #FF8789",
+"n. c #FC7778",
+"'  c #A75047",
+"P  c #B7464C",
+"*X c #EA9092",
+".X c #FF5263",
+"Z  c #B0516F",
+"2  c #121D5F",
+"i. c #592A30",
+"J. c #C64F55",
+"D. c #AC5150",
+"N. c #C8464E",
+"r  c #10205E",
+"L  c #48534B",
+".  c #E1928D",
+"-X c #DA948C",
+"+  c #6D84AE",
+"2. c #1E195B",
+"l  c #07285E",
+"W  c #003072",
+"XX c #B14F46",
+"j. c #CF4459",
+"|  c #6E2445",
+"_  c #636770",
+"=X c #955A4C",
+"u. c #404558",
+"j  c #4A2453",
+":. c #7A5873",
+"y  c #F2FFF6",
+">  c #6C5F79",
+"4. c #613544",
+"9  c #F29296",
+"4  c #42457A",
+"~. c #F7616C",
+"K  c #072265",
+"2X c #D3585A",
+"%  c #364073",
+"q. c #FF6F75",
+"*. c #D74959",
+".. c #091964",
+"z  c #EBFEFF",
+"/. c #F06374",
+"7. c #BD4B55",
+"5. c #BD8699",
+"S. c #BF4250",
+"<  c #162B6E",
+"[. c #FFFFDC",
+/* pixels */
+"        . X o O + @ # $ % & *   ",
+"      = - ; : > , < 1 2 3 4 5 6 ",
+"    7 8 9 0 q w e r t y u i p a ",
+"  s d f g h j k l z x c v b n m ",
+"M N B V C Z A S D z F G H J K L ",
+"P I U Y T R E W Q ! ~ ^ / ( ) _ ",
+"` ' ] [ { } |  ...X.o.O.+.@.#.$.",
+"  %.&.*.=.-.;.:.>.,.<.1.2.3.4.5.",
+"  6.7.8.9.0.q.w.e.r.t.y.u.i.p.a.",
+"s.d.f.g.h.j.k.l.z.x.c.v.b.n.m.M.",
+"N.B.V.C.Z.A.S.D.F.G.H.J.K.L.P.  ",
+"I.U.Y.T.R.E.W.Q.!.~.^./.(.).    ",
+"  _.`.'.].[.{.}.|. X.XXXoX      ",
+"    OX+X@X#X$X%X&X*X=X-X        ",
+"      ;X:X>X,X<X                ",
+"        1X2X3X                  "
+};
diff --git a/pgadmin/include/images/sv/table_changed_sm.xpm b/pgadmin/include/images/sv/table_changed_sm.xpm
new file mode 100644
index 0000000..1e275cc
--- /dev/null
+++ b/pgadmin/include/images/sv/table_changed_sm.xpm
@@ -0,0 +1,152 @@
+/* XPM */
+static const char *table_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 130 2",
+"7. c #EDEFEE",
+"-  c #13539A",
+"m  c #DEDDDB",
+"8. c #2494E8",
+"@  c #283E75",
+"I  c #CFCBCC",
+"*. c #AAACA9",
+"4  c #DCE3E9",
+"*  c #2297E7",
+"X  c #828FB4",
+"3  c #CBDDEB",
+"_  c #CDCECF",
+"k  c #DCDDDF",
+"P  c #E1E1E1",
+"!  c #DCDDE1",
+"+. c #F0F0F0",
+"7  c #FFFFFF",
+"5  c #263B73",
+"{  c #9E9E9E",
+"W  c #999DA8",
+"4. c #E4E5E0",
+"&  c #2094E7",
+"u  c #2094E9",
+"1  c #96D1FD",
+"s  c #65B9F5",
+"p  c #85CBFC",
+"2  c #ACD5F1",
+"t. c #4AABF0",
+"9  c #293F76",
+"F  c #152961",
+"b  c #384569",
+"<  c #8ACCFC",
+">  c #7481A6",
+"|  c #E7E9E8",
+"[  c #0D3E60",
+"l  c #DDDEE0",
+"t  c #63B9F6",
+"2. c #E2E2E2",
+";. c #B0AEB1",
+"D  c #092469",
+"c  c #132963",
+"$  c #09246B",
+"`  c #909090",
+"n  c #2195E8",
+"h  c #B4D4ED",
+"   c None",
+"R  c #0C256A",
+"o  c #3E538B",
+"'  c #616061",
+"e  c #7AC7FD",
+"K  c #A7A7A7",
+"B  c #A7A7A9",
+"Q  c #E3E3E3",
+"]  c #414241",
+"y  c #0A256A",
+"9. c #89CDFE",
+"x  c #323F63",
+"J  c #A5A7A6",
+"(  c #E1E3E0",
+"o. c #AFAFAF",
+"i. c #279AEA",
+">. c #B4B3B1",
+"+  c #8C96B3",
+"&. c #AAA8A9",
+"$. c #E1E0DE",
+"i  c #87CDFE",
+"T  c #12275E",
+"q  c #87CDFF",
+"8  c #0D266A",
+"f  c #172B63",
+"#  c #0D266B",
+"L  c #A8A8AA",
+"3. c #E4E4E4",
+",. c #EEEFF1",
+"r  c #6FC0F8",
+"j  c #DDDDDD",
+"e. c #63B8F8",
+"Y  c #273559",
+":  c #273E77",
+"Z  c #2C3653",
+"U  c #686C76",
+"u. c #329DEB",
+".. c #A9A9A7",
+"%. c #A9A9A9",
+"p. c #2194E4",
+"d  c #0C2762",
+"<. c #2194E5",
+"5. c #EAECEB",
+")  c #E5E5E3",
+"1. c #E0E1E3",
+"=. c #E5E5E7",
+"r. c #55B3F3",
+"w. c #70C1F9",
+":. c #ACB0AF",
+"a  c #7AC6FA",
+"z  c #DEDEDC",
+"=  c #2495E5",
+"@. c #EDEDEB",
+"y. c #3FA3EF",
+"A  c #142961",
+"H  c #878B96",
+"%  c #2295E6",
+"6. c #EBEDEC",
+"0  c #2295E8",
+"N  c #E6E6E6",
+";  c #0B3174",
+"^  c #E1DFE0",
+"G  c #3F4A66",
+"O. c #F0EEEF",
+"#. c #2095E4",
+"~  c #DFDFDF",
+"X. c #E4E3E1",
+".  c #DADEE9",
+"S  c #0B2569",
+"v  c #152A64",
+"C  c #797D87",
+"E  c #092561",
+"0. c #83CCFF",
+"w  c #83C9FA",
+"/  c #E2E0E1",
+"O  c #132D71",
+"g  c #2196E6",
+"M  c #E5E7E6",
+"V  c #E0E0E0",
+"q. c #7CC5FC",
+"6  c #0C266A",
+"-. c #EAE8E9",
+" . c #EAE8EB",
+",  c #1F96E8",
+"}  c #DEE0DF",
+/* pixels */
+"                                ",
+"                . X o O o X .   ",
+"              . + @ # $ # @ + . ",
+"  % & & * = & - ; $ $ $ $ $ : > ",
+"  , < 1 2 3 4 5 6 $ $ 7 7 $ 8 9 ",
+"  0 q w e r t y $ $ 7 $ $ $ $ 8 ",
+"  u i p a r s d y $ 7 $ $ $ 6 f ",
+"  g h j k l z x c $ $ 7 7 $ v b ",
+"  n m M N B V C Z A S $ D F G H ",
+"  & z J K L P I U Y T R E b W Q ",
+"  % ! ~ ^ / ( ) _ ` ' ] [ { Q   ",
+"  0 } |  ...X.M o.O.+.@.#.      ",
+"  , $.%.&.*.=.-.;.:.>.,.<.      ",
+"  0 1.2.3.4.N 5.6.@.7.+.0       ",
+"  8.9.0.q.w.e.r.t.y.u.i.p.      ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/table_missing_sm.xpm b/pgadmin/include/images/sv/table_missing_sm.xpm
new file mode 100644
index 0000000..b2ee715
--- /dev/null
+++ b/pgadmin/include/images/sv/table_missing_sm.xpm
@@ -0,0 +1,161 @@
+/* XPM */
+static const char *table_missing_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 139 2",
+"y. c #EDEFEE",
+"P  c #DEDDDB",
+"u. c #2494E8",
+"b  c #4694CB",
+"w  c #D11A1A",
+"3. c #AAACA9",
+":  c #1F87CF",
+"0  c #DCE3E9",
+"-  c #2297E7",
+",  c #F7110E",
+"9  c #CBDDEB",
+"A  c #DCDDDF",
+")  c #E1E1E1",
+"{  c #DCDDE1",
+":. c #F0F0F0",
+"h  c #FFFFFF",
+"+. c #EBE9EC",
+"%  c #D41E1F",
+"m  c #FE0300",
+"r. c #E4E5E0",
+"=  c #2094E7",
+"l  c #2094E9",
+"7  c #96D1FD",
+"<  c #FE0000",
+"O. c #E9E9E9",
+"j  c #FE0002",
+"v  c #65B9F5",
+"x  c #85CBFC",
+"8  c #ACD5F1",
+"2  c #FE0003",
+"g. c #4AABF0",
+"3  c #FA0F0F",
+"'  c #9C9E9D",
+"6  c #8ACCFC",
+"W  c #A16D77",
+"@  c #C17F7F",
+"%. c #E7E9E8",
+"o  c #D3D3D3",
+"S  c #DDDEE0",
+"a  c #63B9F6",
+"w. c #E2E2E2",
+"6. c #B0AEB1",
+"B  c #D51F1D",
+"L  c #2195E8",
+"C  c #B4D4ED",
+"F  c #CCCCCC",
+"   c None",
+"N  c #FF0100",
+"r  c #FF0101",
+"e  c #FF0103",
+".  c #F9F9F9",
+"i  c #7AC7FD",
+">  c #6C5573",
+"/  c #A7A7A7",
+"H  c #EF0B0E",
+"Y  c #A7A7A9",
+"d  c #F60303",
+"k  c #F60304",
+"J  c #F91013",
+"i. c #89CDFE",
+"_  c #E8E4E5",
+"^  c #A5A7A6",
+"E  c #919191",
+".. c #E1E3E0",
+"-. c #AFAFAF",
+"k. c #279AEA",
+"8. c #B4B3B1",
+"q  c #BEBEBE",
+"2. c #AAA8A9",
+"<. c #E1E0DE",
+"o. c #E6E7E9",
+"z  c #87CDFE",
+"y  c #87CDFF",
+"`  c #A8A8A8",
+"1  c #FE0200",
+"(  c #A8A8AA",
+"e. c #E4E4E4",
+"9. c #EEEFF1",
+"p  c #6FC0F8",
+"K  c #C17E7E",
+"Z  c #DDDDDD",
+"d. c #63B8F8",
+"#  c #D51E1E",
+"j. c #329DEB",
+"*. c #A9A9A7",
+"1. c #A9A9A9",
+"l. c #2194E4",
+"]  c #B8B8B7",
+"0. c #2194E5",
+"@. c #EAECEB",
+"f  c #FEFFFA",
+"X. c #E5E5E3",
+"q. c #E0E1E3",
+"4. c #E5E5E7",
+"f. c #55B3F3",
+"s. c #70C1F9",
+"7. c #ACB0AF",
+"c  c #7AC6FA",
+"D  c #DEDEDC",
+"M  c #FD0000",
+";  c #2495E5",
+">. c #EDEDEB",
+"R  c #DEDEDE",
+"h. c #3FA3EF",
+"Q  c #D11B1B",
+"~  c #BB111A",
+"&  c #C07F7F",
+"*  c #2295E6",
+"t. c #EBEDEC",
+"t  c #2295E8",
+"+  c #D7D7D7",
+"U  c #E6E6E6",
+"|  c #E1DFE0",
+";. c #F0EEEF",
+"g  c #FFFDFE",
+",. c #2095E4",
+"s  c #448CC0",
+"}  c #DFDFDF",
+"=. c #E4E3E1",
+"!  c #F70303",
+"$  c #F70305",
+"[  c #1B7CBE",
+"O  c #C9C9C9",
+"p. c #83CCFF",
+"4  c #C17D7E",
+"X  c #E7E7E7",
+"u  c #83C9FA",
+"G  c #A16871",
+" . c #E2E0E1",
+"V  c #2196E6",
+"n  c #BF131B",
+"I  c #E5E7E6",
+"T  c #E0E0E0",
+"a. c #7CC5FC",
+"5. c #EAE8E9",
+"&. c #EAE8EB",
+"5  c #1F96E8",
+"#. c #1F96EA",
+"$. c #DEE0DF",
+/* pixels */
+"                                ",
+"                . X o O o X .   ",
+"              . + @ # $ % & + . ",
+"  * = = - ; = : > , < 1 2 3 4 X ",
+"  5 6 7 8 9 0 q w e < e < r # o ",
+"  t y u i p a s d 2 f g h j k O ",
+"  l z x c p v b n m r e M N B o ",
+"  V C Z A S D F G H M < < J K X ",
+"  L P I U Y T R E W Q ! ~ @ + . ",
+"  = D ^ / ( ) _ ` ' E ] [ X .   ",
+"  * { } |  ...X.o.O.+.@.#.      ",
+"  t $.%.&.*.=.I -.;.:.>.,.      ",
+"  5 <.1.2.3.4.5.6.7.8.9.0.      ",
+"  t q.w.e.r.U @.t.>.y.:.t       ",
+"  u.i.p.a.s.d.f.g.h.j.k.l.      ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/table_present_sm.xpm b/pgadmin/include/images/sv/table_present_sm.xpm
new file mode 100644
index 0000000..ad90739
--- /dev/null
+++ b/pgadmin/include/images/sv/table_present_sm.xpm
@@ -0,0 +1,159 @@
+/* XPM */
+static const char *table_present_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 137 2",
+"r. c #EDEFEE",
+"J  c #DEDDDB",
+"n  c #0A7A00",
+"t. c #2494E8",
+"1. c #AAACA9",
+"w  c #3A8B33",
+"4  c #DCE3E9",
+"$  c #2297E7",
+"3  c #CBDDEB",
+"8  c #087A00",
+"V  c #DCDDDF",
+"-  c #087A01",
+"A  c #E1E1E1",
+"]  c #DCDDE1",
+"-. c #F0F0F0",
+"f  c #FFFFFD",
+"s  c #FFFFFF",
+"o. c #EBE9EC",
+"w. c #E4E5E0",
+"#  c #2094E7",
+"j  c #2094E9",
+"v  c #0E6513",
+"1  c #96D1FD",
+"X. c #E9E9E9",
+"x  c #65B9F5",
+"l  c #85CBFC",
+"2  c #ACD5F1",
+"d. c #4AABF0",
+"c  c #54B3F5",
+"<  c #8ACCFC",
+"R  c #0B7803",
+"a  c #0B7804",
+"#. c #E7E9E8",
+";  c #097B01",
+"C  c #DDDEE0",
+"g  c #097B02",
+"i  c #63B9F6",
+"0. c #E2E2E2",
+"4. c #B0AEB1",
+"o  c #157D0B",
+"O  c #4D9F48",
+"H  c #2195E8",
+"N  c #B4D4ED",
+"+  c #BFDDBD",
+"   c None",
+"y  c #7AC7FD",
+"~  c #A7A7A7",
+"L  c #A7A7A9",
+"I  c #E3E3E3",
+"q  c #0A7901",
+"y. c #89CDFE",
+":  c #1B8212",
+"/  c #E8E4E5",
+"!  c #A5A7A6",
+"7  c #087C00",
+"|  c #E1E3E0",
+"S  c #4B735B",
+"*. c #AFAFAF",
+"h. c #279AEA",
+"6. c #B4B3B1",
+"<. c #AAA8A9",
+">. c #E1E0DE",
+".. c #E6E7E9",
+"k  c #87CDFE",
+"r  c #87CDFF",
+"m  c #1A6C14",
+"9  c #FFFEFF",
+"*  c #329AAC",
+"U  c #7B7B7B",
+"p  c #56B2F3",
+"h  c #0D7A08",
+"^  c #A8A8AA",
+"Q  c #B7B7B7",
+"q. c #E4E4E4",
+"7. c #EEEFF1",
+"0  c #0B7A01",
+"b  c #0B7A02",
+"u  c #6FC0F8",
+"B  c #DDDDDD",
+"a. c #63B8F8",
+".  c #C1DCBD",
+"g. c #329DEB",
+"%. c #A9A9A7",
+",. c #A9A9A9",
+"j. c #2194E4",
+"8. c #2194E5",
+"O. c #EAECEB",
+" . c #E5E5E3",
+"9. c #E0E1E3",
+"2. c #E5E5E7",
+"s. c #55B3F3",
+"p. c #70C1F9",
+"5. c #ACB0AF",
+"G  c #688666",
+"z  c #7AC6FA",
+">  c #BDDCBC",
+"d  c #FCFFFF",
+"Z  c #DEDEDC",
+"%  c #2495E5",
+";. c #EDEDEB",
+"f. c #3FA3EF",
+"`  c #414141",
+"_  c #505050",
+"D  c #0A7B0F",
+"&  c #2295E5",
+"@  c #2295E6",
+"e. c #EBEDEC",
+"e  c #2295E8",
+"5  c #E6E6E6",
+"{  c #E1DFE0",
+")  c #7B7D7C",
+"=. c #F0EEEF",
+"W  c #4B694A",
+"6  c #33852E",
+"'  c #0F456A",
+"Y  c #466243",
+":. c #2095E4",
+"E  c #096210",
+"[  c #DFDFDF",
+"&. c #E4E3E1",
+"u. c #83CCFF",
+"=  c #158111",
+"t  c #83C9FA",
+"}  c #E2E0E1",
+"T  c #166811",
+"X  c #4DA048",
+"F  c #1A7F0D",
+"M  c #2196E6",
+"K  c #E5E7E6",
+"P  c #E0E0E0",
+"i. c #7CC5FC",
+"3. c #EAE8E9",
+"$. c #EAE8EB",
+",  c #1F96E8",
+"+. c #1F96EA",
+"(  c #ACACAC",
+"@. c #DEE0DF",
+/* pixels */
+"                                ",
+"                                ",
+"                  . X o O +     ",
+"  @ # # $ % # & * = - ; ; : >   ",
+"  , < 1 2 3 4 5 6 7 8 9 0 q w   ",
+"  e r t y u i p a q s d f g h   ",
+"  j k l z u x c v b n f 0 - m   ",
+"  M N B V C Z A S D ; q ; F G   ",
+"  H J K 5 L P I U Y T R E W Q   ",
+"  # Z ! ~ ^ A / ( ) _ ` ' Q     ",
+"  @ ] [ { } |  ...X.o.O.+.      ",
+"  e @.#.$.%.&.K *.=.-.;.:.      ",
+"  , >.,.<.1.2.3.4.5.6.7.8.      ",
+"  e 9.0.q.w.5 O.e.;.r.-.e       ",
+"  t.y.u.i.p.a.s.d.f.g.h.j.      ",
+"                                "
+};
diff --git a/pgadmin/include/images/sv/tables_changed_sm.xpm b/pgadmin/include/images/sv/tables_changed_sm.xpm
new file mode 100644
index 0000000..96b63e2
--- /dev/null
+++ b/pgadmin/include/images/sv/tables_changed_sm.xpm
@@ -0,0 +1,185 @@
+/* XPM */
+static const char *tables_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 163 2",
+"3  c #C5C9D5",
+">  c #95D0FC",
+"w. c #E8E8E8",
+"h. c #90C9F4",
+"v  c #1D96E7",
+"u  c #283E78",
+"0  c #8C97B3",
+"4. c #EBECE7",
+"*  c #828FB4",
+"f  c #CBDDEB",
+"y. c #E1E1DF",
+"J  c #0D2765",
+"n  c #DCDDDF",
+"<. c #E1E1E1",
+";. c #E1E1E3",
+"j  c #FFFFFF",
+"k  c #0D276B",
+"z. c #EBE9EA",
+"$  c #0E3D86",
+"]  c #858A96",
+"7. c #DFE1DC",
+"2. c #ADADAD",
+"r  c #2094E7",
+";  c #2094E9",
+"S  c #DFDEDC",
+"e. c #E9E9E9",
+"'  c #C6C4C5",
+"!  c #0C3161",
+"m  c #8ACCFC",
+":. c #A6A6A6",
+"G. c #63B9F6",
+"S. c #83CBFD",
+"0. c #E2E2E2",
+"s. c #F1F1F1",
+"W  c #092469",
+")  c #DDDBDC",
+"7  c #09246B",
+"#  c #155BA8",
+"O  c #2195E8",
+".  c #2195EA",
+"-  c None",
+"B  c #112962",
+"<  c #CADBEB",
+"t. c #EAEAEA",
+"J. c #4BACF1",
+"p  c #86CCFF",
+"&  c #3E538A",
+">. c #A7A7A7",
+"Q  c #0A2561",
+"5. c #90CBF5",
+"M  c #89D0FE",
+"s  c #95CFF7",
+"6  c #0A256B",
+"n. c #2493E5",
+"o. c #DEDCDD",
+"w  c #89CDFE",
+"9  c #283D75",
+"_  c #B5D5EA",
+"z  c #B5D5EC",
+" . c #1F83CC",
+"O. c #E6E7E9",
+"N. c #EBEBEB",
+"%. c #303030",
+"x  c #87CDFF",
+"$. c #5D5D5D",
+"&. c #626160",
+"|  c #54779A",
+"H. c #56B2F5",
+"D  c #B3D5EE",
+",. c #A8A8A8",
+"k. c #A8A8AA",
+"j. c #DFE0E2",
+"M. c #E4E4E4",
+"a. c #EEEFF1",
+"K. c #40A2E9",
+"F. c #6FC0F8",
+"l  c #293E76",
+"}  c #334065",
+"N  c #94D0F5",
+"L  c #0C3065",
+"I  c #DDDDDD",
+"d. c #ECECEC",
+"B. c #ECECEE",
+"a  c #88CEFF",
+"2  c #E7E5E6",
+"y  c #0C3075",
+"L. c #329DEB",
+"e  c #52AFF2",
+"p. c #AEB0AF",
+"U  c #88CBFF",
+"l. c #A9A9A9",
+"m. c #2194E5",
+"@  c #1E84D5",
+"+. c #E5E5E5",
+"C. c #EFEDEE",
+"A. c #90CAF0",
+"t  c #13549B",
+"=. c #CFCFCF",
+"X. c #DEDEDC",
+"P  c #DEDEDE",
+"Y  c #84CBFF",
+"C  c #0A2469",
+"F  c #89CCFF",
+"4  c #7D89A6",
+"u. c #AAAAAA",
+"^  c #2295E5",
+"o  c #2295E6",
+"@. c #969495",
+"q  c #2295E8",
+"q. c #E6E6E6",
+"5  c #213872",
+"+  c #2095E4",
+"X  c #2095E5",
+"D. c #7BC7FB",
+"v. c #B2B2B4",
+"R  c #1D3B63",
+"g. c #91CBF3",
+"/  c #DFDFDD",
+",  c #ACD6EF",
+"~  c #12558A",
+"8. c #DFDFDF",
+"=  c #DADEE9",
+"H  c #1D3B6A",
+"V. c #EEEEF0",
+"V  c #0B2569",
+"{  c #152A62",
+"A  c #1E95E7",
+"(  c #1E95E9",
+"i  c #7482A6",
+"x. c #B0AFAD",
+"I. c #2396E7",
+"K  c #092564",
+"i. c #E7E7E7",
+"b  c #09256B",
+"G  c #83C9FC",
+"[  c #313F63",
+"%  c #132D71",
+"c  c #52B1F5",
+"P. c #269AE7",
+"   c #2196E6",
+"#. c #8B8A8B",
+"r. c #EAEBE6",
+"3. c #AEAFB3",
+"E  c #0C2661",
+".. c #E0E0DE",
+"`  c #DBDCDE",
+"b. c #EFEFED",
+"9. c #E0E0E0",
+"Z. c #EFEFF1",
+"h  c #0C266A",
+"6. c #92C9F2",
+"8  c #0C266B",
+":  c #8BCEFB",
+"g  c #253A73",
+"*. c #939594",
+"d  c #ADD4F3",
+"-. c #1F96E8",
+"f. c #1F96EA",
+"Z  c #0A2662",
+"1  c #DEE3E7",
+"1. c #ACACAC",
+"c. c #B1B0AE",
+"T  c #426E96",
+/* pixels */
+"    . X o X O + @ # $ % & * = - ",
+"; : > , < 1 2 3 4 5 6 7 8 9 0 = ",
+"q w e   q o r t y 7 7 7 7 7 u i ",
+"o p O a s d f g h 7 7 j j 7 k l ",
+"  z O x c v   b 7 7 j 7 7 7 7 k ",
+"O n o m X M N B V 7 j 7 7 7 C Z ",
+"A S r D A F G H J 7 7 j j 7 K L ",
+"X P o I o U Y T R E W 7 W Q ! ~ ",
+"^ / ( ) O _ ` ' ] [ { V { } |  .",
+"O ... X.X o.O.+.@.#.$.%.&.*.=.-.",
+"^ ;.q / O I :.>.,.<.+.1.2.3.4.O ",
+"5.6.; 7.r 8.8.9.9.0.q.w.e.r.t.-.",
+"- - q y.O 8.w.e.u.0.i.p.a.s.d.f.",
+"- - g.h.O j.k.l.l.+.z.x.c.v.b.n.",
+"- - - - m.9.0.M.+.q.N.B.V.C.Z.A ",
+"- - - - A.w S.D.F.G.H.J.K.L.P.I."
+};
diff --git a/pgadmin/include/images/sv/unique_changed_sm.xpm b/pgadmin/include/images/sv/unique_changed_sm.xpm
new file mode 100644
index 0000000..7cc760f
--- /dev/null
+++ b/pgadmin/include/images/sv/unique_changed_sm.xpm
@@ -0,0 +1,90 @@
+/* XPM */
+static const char *unique_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 68 1",
+"B c #5E9BDB",
+"n c #696969",
+"G c #83AEE5",
+"X c #828FB4",
+"2 c #FFFFFF",
+"6 c #A7D4E5",
+"0 c #83A5D8",
+"l c #5D6A8F",
+"m c #9E9E9E",
+"d c #597FB8",
+"w c #132954",
+"p c #092469",
+"% c #09246B",
+"f c #507598",
+"b c #0C1C35",
+"u c #11264B",
+"  c None",
+"K c #ACC6EF",
+"7 c #28373E",
+"s c #1B3169",
+"o c #3E538B",
+"; c #324B81",
+"- c #E3E3E3",
+"1 c #0A2569",
+"q c #122A4E",
+"& c #0F296E",
+", c #586B88",
+"8 c #0D265F",
+"4 c #2C66BD",
+"< c #102A65",
+"C c #6E9EDA",
+"> c #314680",
+"+ c #C2C6D1",
+"S c #AACBEC",
+"V c #80AEE3",
+"A c #76A6E3",
+"c c #386186",
+"= c #9DA7C4",
+"v c #35485D",
+"9 c #0A2469",
+"Z c #5E99DC",
+"z c #3B71C2",
+"F c #90B8E7",
+"e c #0B2561",
+". c #DADEE9",
+": c #0B2566",
+"r c #1A316B",
+"a c #0B2569",
+"3 c #10296D",
+"D c #A2C5EA",
+"j c #09225E",
+"i c #0E2660",
+"t c #254678",
+"5 c #203652",
+"O c #132D71",
+"k c #1D326A",
+"* c #364C84",
+"# c #1D326B",
+"@ c #636D8A",
+"h c #162B55",
+"x c #76A2C7",
+"M c #648FCF",
+"y c #2D4258",
+"$ c #0C266A",
+"H c #8CB2E8",
+"N c #76A5DA",
+"J c #A0BFEC",
+"g c #213D5B",
+/* pixels */
+"       .XoOoX.  ",
+"      +@#$%&*=. ",
+"     -;:%%%%%>X ",
+"     ,<1%22%%3o ",
+"    451%2%%%%%O ",
+"   467892%%%%$o ",
+"   04qwe%22%%rX ",
+"     tyuip%as@. ",
+"     dfghj$kl+  ",
+"     zxcvbnm-   ",
+"     MNBV4      ",
+"    44CZA44     ",
+"   4SDFGHJK4    ",
+"   044444440    ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/unique_missing_sm.xpm b/pgadmin/include/images/sv/unique_missing_sm.xpm
new file mode 100644
index 0000000..4a1d531
--- /dev/null
+++ b/pgadmin/include/images/sv/unique_missing_sm.xpm
@@ -0,0 +1,97 @@
+/* XPM */
+static const char *unique_missing_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 75 1",
+"2 c #5B85AE",
+"F c #5E9BDB",
+"y c #8EC6DE",
+"U c #83AEE5",
+"w c #FFFFFF",
+"t c #A7D4E5",
+"% c #D41E1F",
+"f c #83A5D8",
+"8 c #5A8FA9",
+"p c #FE0300",
+"; c #FE0000",
+"7 c #4D83C8",
+"e c #FE0002",
+"> c #FE0003",
+", c #FA0F0F",
+"x c #82B5D9",
+"B c #589BD2",
+"@ c #C17F7F",
+"3 c #C61619",
+"o c #D3D3D3",
+"d c #D51F1D",
+"Z c #85B6E0",
+"A c #5B9CD9",
+"  c None",
+"R c #ACC6EF",
+"s c #FF0100",
+"5 c #FF0101",
+"4 c #FF0103",
+". c #F9F9F9",
+"9 c #F60303",
+"r c #F60304",
+"k c #F91013",
+"N c #72A7D8",
+"- c #F7100E",
+"6 c #2C66BD",
+"m c #D41D1D",
+"c c #4B88B4",
+": c #FE0200",
+"g c #5F95C0",
+"l c #C17E7E",
+"H c #6E9EDA",
+"# c #D51E1E",
+"1 c #8EADDC",
+"0 c #FEFFFA",
+"L c #AACBEC",
+"G c #80AEE3",
+"K c #76A6E3",
+"h c #6C516B",
+"a c #FD0000",
+"C c #24549C",
+"J c #5E99DC",
+"& c #C07F7F",
+"+ c #D7D7D7",
+"q c #FFFDFE",
+"z c #3B71C2",
+"I c #90B8E7",
+"= c #714364",
+"n c #F70303",
+"u c #5893B0",
+"$ c #F70305",
+"v c #775772",
+"* c #7795C4",
+"j c #EE0B0E",
+"i c #C11317",
+"O c #C9C9C9",
+"V c #73A1CB",
+"P c #A2C5EA",
+"b c #BC0C15",
+"< c #C17D7E",
+"X c #E7E7E7",
+"M c #648FCF",
+"S c #80B0E2",
+"Y c #8CB2E8",
+"D c #76A5DA",
+"T c #A0BFEC",
+/* pixels */
+"       .XoOoX.  ",
+"      .+@#$%&+. ",
+"      *=-;:>,<X ",
+"     1234;4;5#o ",
+"    6789>0qwerO ",
+"   6tyuip54asdo ",
+"   f66ghja;;klX ",
+"     zxcvbnm@+. ",
+"     MNBVCOoX.  ",
+"     zZAS6      ",
+"     MDFG6      ",
+"    66HJK66     ",
+"   6LPIUYTR6    ",
+"   f6666666f    ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/unique_present_sm.xpm b/pgadmin/include/images/sv/unique_present_sm.xpm
new file mode 100644
index 0000000..9fbbadf
--- /dev/null
+++ b/pgadmin/include/images/sv/unique_present_sm.xpm
@@ -0,0 +1,95 @@
+/* XPM */
+static const char *unique_present_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 73 1",
+"i c #0A7A00",
+"S c #5E9BDB",
+"r c #8EC6DE",
+"s c #174C3B",
+"7 c #0A7702",
+"P c #83AEE5",
+", c #087A00",
+"% c #087A01",
+"0 c #FFFFFD",
+"8 c #FFFFFF",
+"; c #4F7497",
+"e c #A7D4E5",
+"x c #1A6A13",
+"@ c #83A5D8",
+"5 c #4D83C8",
+"n c #41729A",
+"* c #1C8414",
+"& c #097B01",
+"q c #097B02",
+"$ c #15800F",
+"o c #157D0B",
+"M c #0C1C35",
+"O c #4D9F48",
+"t c #1E323B",
+"V c #85B6E0",
+"C c #5B9CD9",
+": c #0F6611",
+"+ c #BFDDBD",
+"  c None",
+"Y c #ACC6EF",
+"a c #304B61",
+"2 c #0A7901",
+"b c #72A7D8",
+"> c #087C00",
+"k c #32563E",
+"4 c #2C66BD",
+"< c #FFFEFF",
+"j c #182C3A",
+"B c #B7B7B7",
+"w c #127E0D",
+"6 c #345362",
+"1 c #0B7A01",
+"u c #0B7A02",
+". c #C1DCBD",
+"F c #6E9EDA",
+"- c #8EADDC",
+"J c #AACBEC",
+"D c #80AEE3",
+"N c #757575",
+"H c #76A6E3",
+"m c #3A5267",
+"= c #BDDCBC",
+"9 c #FCFFFF",
+"# c #326A71",
+"f c #1B810E",
+"d c #0A7B0F",
+"3 c #4E9F47",
+"G c #5E99DC",
+"c c #93B091",
+"g c #3B71C2",
+"L c #90B8E7",
+"l c #095F0D",
+"y c #0E630F",
+"h c #5F859F",
+"K c #A2C5EA",
+"p c #4DA047",
+"X c #4DA048",
+"v c #648FCF",
+"Z c #80B0E2",
+"I c #8CB2E8",
+"A c #76A5DA",
+"z c #0C7A04",
+"U c #A0BFEC",
+/* pixels */
+"                ",
+"        .XoO+   ",
+"      @#$%&&*=  ",
+"     -;:>,<123  ",
+"    45672890qw  ",
+"   4ertyui01%p  ",
+"   @44asd&2&f=  ",
+"     ghjklzxc   ",
+"     vbnmMNB    ",
+"     gVCZ4      ",
+"     vASD4      ",
+"    44FGH44     ",
+"   4JKLPIUY4    ",
+"   @4444444@    ",
+"                ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/view_changed_sm.xpm b/pgadmin/include/images/sv/view_changed_sm.xpm
new file mode 100644
index 0000000..e057a2a
--- /dev/null
+++ b/pgadmin/include/images/sv/view_changed_sm.xpm
@@ -0,0 +1,83 @@
+/* XPM */
+static const char *view_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 61 1",
+"9 c #E2EEBE",
+"y c #696969",
+"X c #828FB4",
+"e c #E2FF8B",
+"4 c #FFFFFF",
+"Z c #BAEA2E",
+"; c #5D6A8F",
+"7 c #E2FC96",
+", c #B6D658",
+"z c #CBF356",
+"s c #152961",
+"q c #5E5F5B",
+"% c #09246B",
+"M c #DCFC7E",
+"  c None",
+"f c #1B3169",
+"w c #0C2569",
+"2 c #142D56",
+"g c #C4D299",
+"o c #3E538B",
+"C c #BEEC36",
+"b c #B7E826",
+"v c #B7E827",
+"- c #E3E3E3",
+"i c #142A64",
+"& c #0F296E",
+"0 c #E4EAD3",
+"6 c #9EC820",
+"m c #E0FE86",
+"N c #D9FA75",
+"h c #A1A1A1",
+"u c #273559",
+"r c #2B3708",
+"> c #314680",
+"l c #E1FF8B",
+"+ c #C2C6D1",
+"= c #9DA7C4",
+"V c #C3EF40",
+"d c #0A2467",
+"c c #4B6010",
+"8 c #E3F6A7",
+"A c #CDE38D",
+"x c #B1D643",
+"p c #344619",
+"k c #152D56",
+". c #DADEE9",
+"3 c #0B2567",
+": c #1A316B",
+"< c #9CC71C",
+"5 c #10296D",
+"a c #1B2C2F",
+"1 c #617B11",
+"O c #132D71",
+"* c #364C84",
+"# c #1D326B",
+"j c #384B19",
+"@ c #636D8A",
+"B c #C7F14B",
+"$ c #0C266A",
+"t c #0F2756",
+"n c #B7E926",
+/* pixels */
+"        .XoOoX. ",
+"       +@#$%&*=.",
+"      -;:%%%%%>X",
+" ,<<<<123%%44%5o",
+" 67890qw%%4%%%%O",
+" <e<<<rt3%4%%%$o",
+" <e<44yui%%44%:X",
+" <e<4<1pasd%df@.",
+" <e<4<ghjut3k;+ ",
+" <l<4<zx1yrc1-  ",
+" <e<4<<<<4<v<   ",
+" <e<444444<b<   ",
+" <e<<<<<<<<n<   ",
+" <emMNzBVCZb<   ",
+" A<<<<<<<<<<A   ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/view_missing_sm.xpm b/pgadmin/include/images/sv/view_missing_sm.xpm
new file mode 100644
index 0000000..543a852
--- /dev/null
+++ b/pgadmin/include/images/sv/view_missing_sm.xpm
@@ -0,0 +1,90 @@
+/* XPM */
+static const char *view_missing_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 68 1",
+"9 c #E2EEBE",
+"z c #84A818",
+"p c #E2FF8B",
+"y c #FFFFFF",
+"J c #BAEA2E",
+"% c #D41E1F",
+"a c #FE0300",
+"7 c #E2FC96",
+"x c #A8747E",
+"- c #FE0000",
+"< c #B6D658",
+"u c #FE0002",
+": c #FE0003",
+"N c #CBF356",
+"> c #FA0F0F",
+"@ c #C17F7F",
+"o c #D3D3D3",
+"S c #DCFC7E",
+"f c #D51F1D",
+"B c #C7F04B",
+"  c None",
+"d c #FF0100",
+"5 c #FF0101",
+"4 c #FF0103",
+". c #F9F9F9",
+"H c #BEEC36",
+"w c #B6B6B5",
+"V c #B7E826",
+"v c #F60301",
+"C c #B7E827",
+"i c #F60304",
+"j c #F91013",
+"0 c #E4EAD3",
+"6 c #9EC820",
+"A c #E0FE86",
+"; c #FE0200",
+"D c #D9FA75",
+"* c #C17E7D",
+"k c #C17E7E",
+"3 c #C91603",
+"# c #D51E1E",
+"M c #E1FF8B",
+"r c #FEFFFA",
+"m c #90B71E",
+"l c #98C21B",
+"2 c #81A517",
+"= c #F9120F",
+"s c #FD0000",
+"G c #C3EF40",
+"8 c #E3F6A7",
+"K c #CDE38D",
+"& c #C07F7F",
+"+ c #D7D7D7",
+"n c #E6E6E6",
+"c c #C81703",
+"t c #FFFDFE",
+"b c #DCECAC",
+"$ c #F70305",
+"1 c #9CC71C",
+"O c #C9C9C9",
+", c #C17D7E",
+"X c #E7E7E7",
+"g c #AB737B",
+"q c #E5E7DE",
+"F c #C7F14B",
+"e c #F80403",
+"h c #EF0C0E",
+"Z c #B7E926",
+/* pixels */
+"        .XoOoX. ",
+"       .+@#$%&+.",
+"       X*=-;:>,X",
+" <11111234-4-5#o",
+" 67890qwe:rtyuiO",
+" 1p111123a54sdfo",
+" 1p1yyyXghs--jkX",
+" 1p1y11lzxcv3@+.",
+" 1p1y1bnlX2m2X. ",
+" 1M1y1NB1y1V1   ",
+" 1p1y1111y1C1   ",
+" 1p1yyyyyy1V1   ",
+" 1p11111111Z1   ",
+" 1pASDNFGHJV1   ",
+" K1111111111K   ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/view_present_sm.xpm b/pgadmin/include/images/sv/view_present_sm.xpm
new file mode 100644
index 0000000..926b222
--- /dev/null
+++ b/pgadmin/include/images/sv/view_present_sm.xpm
@@ -0,0 +1,89 @@
+/* XPM */
+static const char *view_present_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 67 1",
+"7 c #E2EEBE",
+"s c #0A7A00",
+"u c #E2FF8B",
+", c #087A00",
+"$ c #087A01",
+"r c #FFFFFD",
+"w c #FFFFFF",
+"H c #BAEA2E",
+"x c #136602",
+"p c #136603",
+"5 c #E2FC96",
+"; c #708F14",
+"= c #B6D658",
+"M c #CBF356",
+"& c #1C8414",
+"0 c #6A6A69",
+": c #116602",
+"h c #0B7B0F",
+"% c #097B01",
+"t c #097B02",
+"o c #157D0B",
+"A c #DCFC7E",
+"O c #4D9F48",
+"N c #C7F04B",
+"+ c #BFDDBD",
+"  c None",
+"# c #188110",
+"G c #BEEC36",
+"B c #B7E826",
+"V c #B7E827",
+"2 c #0A7901",
+"8 c #E4EAD3",
+"> c #087C00",
+"k c #2A3608",
+"< c #FFFEFF",
+"4 c #9EC820",
+"Z c #E0FE86",
+"S c #D9FA75",
+"y c #127E0D",
+"1 c #0B7A01",
+"a c #0B7A02",
+"n c #546A11",
+"i c #2B3708",
+". c #C1DCBD",
+"g c #315A42",
+"m c #E1FF8B",
+"f c #757575",
+"@ c #90AF8F",
+"* c #BDDCBC",
+"e c #FCFFFF",
+"F c #C3EF40",
+"6 c #E3F6A7",
+"j c #1B810E",
+"z c #0A7801",
+"3 c #4E9F47",
+"J c #CDE38D",
+"c c #93B091",
+"b c #E6E6E6",
+"l c #466243",
+"v c #DCECAC",
+"- c #9CC71C",
+"d c #4DA047",
+"X c #4DA048",
+"9 c #E5E7DE",
+"D c #C7F14B",
+"C c #B7E926",
+"q c #0C7702",
+/* pixels */
+"                ",
+"         .XoO+  ",
+"        @#$%%&* ",
+" =-----;:>,<123 ",
+" 4567890q2werty ",
+" -u----ipasr1$d ",
+" -u-wwwfgh%2%j* ",
+" -u-w--;kl:zxc  ",
+" -u-w-vb;fin;   ",
+" -m-w-MN-w-B-   ",
+" -u-w----w-V-   ",
+" -u-wwwwww-B-   ",
+" -u--------C-   ",
+" -uZASMDFGHB-   ",
+" J----------J   ",
+"                "
+};
diff --git a/pgadmin/include/images/sv/views_changed_sm.xpm b/pgadmin/include/images/sv/views_changed_sm.xpm
new file mode 100644
index 0000000..38fad66
--- /dev/null
+++ b/pgadmin/include/images/sv/views_changed_sm.xpm
@@ -0,0 +1,154 @@
+/* XPM */
+static const char *views_changed_sm_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 16 132 2",
+"2  c #C5C9D4",
+"L  c #243B3C",
+"f  c #E2EEBE",
+"u  c #283E78",
+"$. c #696969",
+"<  c #E6E8DD",
+"9  c #8C97B3",
+"*  c #828FB4",
+"D  c #E2FF88",
+"p  c #E2FF89",
+"A  c #E2FF8B",
+":. c #FFFFFD",
+"j  c #FFFFFF",
+"k  c #0D276B",
+"{  c #102856",
+"d  c #DFF8A5",
+"O. c #8CB01C",
+"3. c #E0FF8A",
+"s  c #E2FC97",
+"i. c #BFEB36",
+"o. c #FDFFFE",
+">. c #B8E725",
+"=. c #CBF355",
+"+  c #9CC61A",
+"X  c #9CC61C",
+"@  c #85AF26",
+"a. c #B6EA26",
+";. c #9AC91B",
+"i  c #7481A6",
+"y  c #1B375B",
+">  c #E1EFBE",
+"6  c #09246B",
+"&. c #A4CE23",
+"^  c #526E1E",
+"K  c #11295A",
+"-. c #C7F04C",
+"   c None",
+"%  c #112C6C",
+"r  c #9DC71B",
+"e  c #9DC71D",
+"&  c #3E538A",
+"+. c #8A906B",
+"'  c #E3E3E1",
+")  c #9BC718",
+"}  c #0A2567",
+"(  c #9BC71A",
+".  c #9BC71C",
+"Q  c #142A62",
+"H  c #243A3C",
+"8  c #283D75",
+"R  c #99C71E",
+"9. c #E2FE8D",
+"4. c #FFFEFC",
+"w  c #9EC51A",
+"t. c #CDF257",
+"F  c #9EC51C",
+"t  c #496A43",
+"r. c #D9FA77",
+"U  c #9CC819",
+"c  c #0B2667",
+"Z  c #9CC81B",
+"o  c #9CC81D",
+"#  c #517544",
+"4  c #243A71",
+"l  c #293E76",
+"u. c #C4EE42",
+"P  c #9CC51E",
+"0. c #9AC81D",
+"[  c #233B3C",
+"*. c #9AC81F",
+"z  c #E3FF8A",
+"<. c #E3FF8C",
+"#. c #2B3707",
+"/  c #E3FF8E",
+"g  c #E3EBD3",
+"y. c #C7F24A",
+"x  c #9FC61D",
+"q  c #E1FF89",
+"T  c #E1FF8B",
+"Y  c #E1FF8F",
+"p. c #B9EA2C",
+"6. c #FEFFFF",
+"|  c #162C63",
+"h  c #253B71",
+"]  c #5F7C21",
+"W  c #3E4966",
+"w. c #DFFF84",
+"~  c #2E4434",
+"S  c #9DC61F",
+"J  c #0F2859",
+"-  c #9DC620",
+"3  c #7F89A5",
+"O  c #9BC91E",
+"M  c #E3F6A5",
+"1. c #9BC61E",
+"@. c #5F5F5F",
+"G  c #9BC61F",
+",. c #CDE38E",
+"C  c #12295A",
+"1  c #E6E6E6",
+"s. c #CBE38D",
+".. c #8CB11A",
+";  c #E2FD92",
+"n  c #9EC720",
+"a  c #9EC721",
+"m  c #E2FD96",
+"`  c #9CC718",
+"=  c #DADEE9",
+"N  c #152A5F",
+"V  c #0B2568",
+"B  c #0B2569",
+"e. c #DEFD7E",
+"0  c #9CC71F",
+"E  c #888C96",
+",  c #E5EAD3",
+"2. c #B6E825",
+"%. c #617B11",
+"$  c #28475A",
+"q. c #E3FE89",
+":  c #E2F7A8",
+"_  c #E3FE8B",
+" . c #6E9027",
+"I  c #E1FE88",
+"b  c #E1FE8A",
+"8. c #9DC819",
+"7. c #FEFEFC",
+"5. c #FEFEFE",
+"v  c #0C2669",
+"5  c #0C266A",
+"7  c #0C266B",
+"X. c #9DC820",
+"!  c #0F2756",
+/* pixels */
+"  . X o o o O + @ # $ % & * =   ",
+"- ; : > , < 1 2 3 4 5 6 7 8 9 = ",
+"0 q o w e r e t y 6 6 6 6 6 u i ",
+"o p a s d f g h 5 6 6 j j 6 k l ",
+"e z X p x + o c 6 6 j 6 6 6 6 v ",
+"e b . p n m M N B 6 j 6 6 6 V C ",
+"Z A S D F p G H J 6 6 j j 6 K L ",
+"P I U Y - T R E W Q B 6 B ! ~ ^ ",
+"r / ( q ) _ ` ' ] [ { } | L  ...",
+"X b X p r q X.o.O.+.@.#.$.%.&.r ",
+"( / o A Z A r j *.=.-.;.:.. >.. ",
+",.. F <.0 q ( :.X o ` S j 1.2.;.",
+"    o 3.r <.X 4.:.j 5.6.7.Z 2.0 ",
+"      8.G 9.;.P . 0.o + e e >.+ ",
+"        S q.w.e.r.t.y.u.i.p.a.r ",
+"          0 o 0 . e Z ( 1.e S s."
+};
diff --git a/pgadmin/include/images/sv/white.xpm b/pgadmin/include/images/sv/white.xpm
new file mode 100644
index 0000000..d506434
--- /dev/null
+++ b/pgadmin/include/images/sv/white.xpm
@@ -0,0 +1,20 @@
+/* XPM */
+static const char *white_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"15 13 1 1",
+"  c #FFFFFF",
+/* pixels */
+"               ",
+"               ",
+"               ",
+"               ",
+"               ",
+"               ",
+"               ",
+"               ",
+"               ",
+"               ",
+"               ",
+"               ",
+"               "
+};
diff --git a/pgadmin/include/images/sv/yellow.xpm b/pgadmin/include/images/sv/yellow.xpm
new file mode 100644
index 0000000..de1835c
--- /dev/null
+++ b/pgadmin/include/images/sv/yellow.xpm
@@ -0,0 +1,26 @@
+/* XPM */
+static const char *yellow_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"15 13 7 1",
+". c #ECEA95",
+"o c #ECEA97",
+"  c #EAEA94",
+"@ c #EAE996",
+"X c #EAE893",
+"+ c #EBE994",
+"O c #EBE996",
+/* pixels */
+" .XoO++ +++++++",
+"+.X++++++++++++",
+"O++++++++++++++",
+"OO+  ++++++++++",
+"OO+  ++++++++++",
+"OO+++++++++++++",
+"OO+++++++++++++",
+"@++++++ +++++++",
+"O++++++++++++++",
+"O++++++++++++++",
+"O++++++++++++++",
+"O++++++++++++++",
+"O++++++++++++++"
+};
diff --git a/pgadmin/include/module.mk b/pgadmin/include/module.mk
index ac678fb..9c73ca8 100644
--- a/pgadmin/include/module.mk
+++ b/pgadmin/include/module.mk
@@ -32,5 +32,6 @@ include $(srcdir)/include/pgscript/module.mk
 include $(srcdir)/include/schema/module.mk
 include $(srcdir)/include/slony/module.mk
 include $(srcdir)/include/gqb/module.mk
+include $(srcdir)/include/sv/module.mk
 include $(srcdir)/include/utils/module.mk
 
diff --git a/pgadmin/include/schema/pgColumn.h b/pgadmin/include/schema/pgColumn.h
index 97337bd..92992c4 100644
--- a/pgadmin/include/schema/pgColumn.h
+++ b/pgadmin/include/schema/pgColumn.h
@@ -91,6 +91,7 @@ public:
     wxString GetSerialSchema() const { return serialSchema; }
     void iSetSerialSchema(const wxString &s) { serialSchema=s; }
     void iSetPkCols(const wxString &s) { pkCols = s; }
+	void SetPK();
     void iSetIsFK(const bool b) { isFK = b; }
     wxArrayString& GetVariables() { return variables; }
 
diff --git a/pgadmin/include/schema/pgForeignKey.h b/pgadmin/include/schema/pgForeignKey.h
index 9693580..e63ad89 100644
--- a/pgadmin/include/schema/pgForeignKey.h
+++ b/pgadmin/include/schema/pgForeignKey.h
@@ -68,6 +68,8 @@ public:
     wxString GetQuotedRefColumns() const { return quotedRefColumns; }
     wxString GetCoveringIndex() const { return coveringIndex; }
 
+	void ReadFkColumnInfo();
+
     bool DropObject(wxFrame *frame, ctlTree *browser, bool cascaded);
     wxString GetConstraint();
     wxString GetSql(ctlTree *browser);
diff --git a/pgadmin/include/schema/pgIndex.h b/pgadmin/include/schema/pgIndex.h
index 5276782..9981ecb 100644
--- a/pgadmin/include/schema/pgIndex.h
+++ b/pgadmin/include/schema/pgIndex.h
@@ -111,6 +111,7 @@ private:
 class pgIndex : public pgIndexBase
 {
 public:
+	void ReadIndexColumnInfo();
     pgIndex(pgTable *newTable, const wxString& newName = wxT(""));
 };
 
diff --git a/pgadmin/include/schema/pgIndexConstraint.h b/pgadmin/include/schema/pgIndexConstraint.h
index 0e94f6e..b3099de 100644
--- a/pgadmin/include/schema/pgIndexConstraint.h
+++ b/pgadmin/include/schema/pgIndexConstraint.h
@@ -31,6 +31,7 @@ public:
 protected:
     pgIndexConstraint(pgTable *newTable, pgaFactory &factory, const wxString& newName)
         : pgIndexBase(newTable, factory, newName) {}
+	void ReadColumnInfo();
 
 private:
     OID constraintOid;
@@ -54,6 +55,7 @@ public:
 
     pgObject *Refresh(ctlTree *browser, const wxTreeItemId item);
     bool CanCreate() { return false; }
+	void ReadPkColumnInfo();
 };
 
 
@@ -73,6 +75,7 @@ public:
         : pgIndexConstraint(newTable, uniqueFactory, newName) {}
 
     pgObject *Refresh(ctlTree *browser, const wxTreeItemId item);
+	void ReadUniqueColumnInfo();
 };
 
 
diff --git a/pgadmin/include/schema/pgObject.h b/pgadmin/include/schema/pgObject.h
index 4d8a473..c8e8ee9 100644
--- a/pgadmin/include/schema/pgObject.h
+++ b/pgadmin/include/schema/pgObject.h
@@ -131,6 +131,8 @@ public:
     void ShowTree(frmMain *form, ctlTree *browser, ctlListView *properties, ctlSQLBox *sqlPane);
 
     wxTreeItemId AppendBrowserItem(ctlTree *browser, pgObject *object);
+	bool GetExpandedStatus();
+	void SetExpandedStatus();
     
     virtual wxString GetHelpPage(bool forCreate) const;
     virtual wxString GetFullName() { return name; }
diff --git a/pgadmin/include/schema/pgSchema.h b/pgadmin/include/schema/pgSchema.h
index f246f00..a92006e 100644
--- a/pgadmin/include/schema/pgSchema.h
+++ b/pgadmin/include/schema/pgSchema.h
@@ -80,7 +80,7 @@ public:
     void iSetDefPrivsOnTables(const wxString& privs) { m_defPrivsOnTables = privs; }
     void iSetDefPrivsOnSeqs(const wxString& privs) { m_defPrivsOnSeqs = privs; }
     void iSetDefPrivsOnFuncs(const wxString& privs) { m_defPrivsOnFuncs = privs; }
-
+	
     wxString GetDefPrivsOnTables() { return m_defPrivsOnTables; }
     wxString GetDefPrivsOnSequences() { return m_defPrivsOnSeqs; }
     wxString GetDefPrivsOnFunctions() { return m_defPrivsOnFuncs; }
diff --git a/pgadmin/include/sv/dlgAuthServer.h b/pgadmin/include/sv/dlgAuthServer.h
new file mode 100644
index 0000000..d0d4405
--- /dev/null
+++ b/pgadmin/include/sv/dlgAuthServer.h
@@ -0,0 +1,78 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: dlgAuthServer.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dlgAuthServer.h - User authentication dialog for sync viewer
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "wx/wx.h"
+#include "wx/image.h"
+#include "wx/xrc/xmlres.h"
+#include "wx/treectrl.h"
+#include "ctl/ctlMenuToolbar.h"
+
+#ifndef DLG_AUTH_SERVER_H
+#define DLG_AUTH_SERVER_H
+
+
+class pgServerCollection;
+class ctlTree;
+class pgServer;
+class frmMain;
+class menuFactoryList; 
+class wxMenu; 
+class dlgDbDiff;
+
+
+class dlgAuthServer:public pgDialog
+{
+public:
+	dlgAuthServer(wxWindow *form);
+	~dlgAuthServer();
+	
+	void CreateTree(wxWindow *p);
+	void onOK(wxCommandEvent& event);
+	void onCancel(wxCommandEvent& event);
+	void OnSelActivatedSrc(wxTreeEvent &event);
+	void OnSelActivatedTrg(wxTreeEvent &event);
+	void OnTreeSelChanged(wxTreeEvent &event);
+	void DialogClose(wxCloseEvent &event);
+	void OnSrcGetSelection(wxTreeEvent &event);
+	void OnTrgGetSelection(wxTreeEvent &event);
+
+	DECLARE_EVENT_TABLE()
+
+private:
+	void RetrieveServers(ctlTree * tree,pgServerCollection *);
+	int ReconnectServer(pgServer *server, bool restore=true);
+	wxTreeItemId FindServer(ctlTree *,wxString serverdesc,wxString name,int port);
+
+	pgServerCollection *serversObjSrc;
+	pgServerCollection *serversObjTrg;
+	ctlTree *treectrlsrc;
+	ctlTree *treectrltrg;
+	frmMain *dlgParent;
+	wxTreeItemId denyCollapseItem;
+	pgServer *SourceServer;
+	pgServer *TargetServer;
+	dlgDbDiff *dbDiff;
+	pgObject *sourcedb;
+	pgObject *targetdb;
+	wxTreeItemId rootsrc;
+	wxTreeItemId roottrg;
+	wxButton *compareDiffBtn;
+	bool srcDbSel;
+	bool trgDbSel;
+	
+};
+class SyncVisualizerFactory:public actionFactory
+{
+public:
+	SyncVisualizerFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/dlgDbDiff.h b/pgadmin/include/sv/dlgDbDiff.h
new file mode 100644
index 0000000..dfd5689
--- /dev/null
+++ b/pgadmin/include/sv/dlgDbDiff.h
@@ -0,0 +1,91 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: dlgDbDiff.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dlgDbDiff.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "wx/wx.h"
+#include "wx/image.h"
+#include "wx/xrc/xmlres.h"
+#include "wx/treectrl.h"
+#include "wx/notebook.h"
+#include "wx/grid.h"
+
+#ifndef DLG_DB_DIFF_H
+#define DLG_DB_DIFF_H
+
+class dlgAuthServer;
+class pgServer;
+class pgDatabase;
+class DiffSystem;
+class ctlListView;
+class ctlSQLBox;
+class dlgDiffObjectViewer;
+
+enum CTRL_ID{
+	ID_GRID_PANEL=5000,
+	ID_LEG_PANEL,
+	ID_GRID
+};
+extern CTRL_ID ctlId;
+
+class dlgDbDiff:public pgDialog
+{
+public:
+	dlgDbDiff();
+	dlgDbDiff(dlgAuthServer *parentDialog,pgServer *src, pgServer *trg,pgObject *srcdb,pgObject *trgdb);
+	~dlgDbDiff();
+	
+	void CreateTree();
+	void Load(wxTreeItemId dbid, ctlTree * tree, bool firstTime);
+	void CreateNoteBookTabs();
+
+	void CreateSchemaTab(wxNotebook * parent);
+	wxPanel *CreateLegendTab(wxNotebook *present);
+
+	void onSync(wxCommandEvent& event);
+	void onDiffViewer(wxCommandEvent& event);
+	void onCancel(wxCommandEvent& event);
+	void OnSelActivatedSrcDb(wxTreeEvent &event);
+	void OnSelActivatedTrgDb(wxTreeEvent &event);
+	void OnExpand(wxTreeEvent &event);
+	void OnSrcGetSelection(wxTreeEvent &event);
+	
+	void RefreshTargetTree(wxTreeItemId dbid);
+	void Refresh(pgObject *data);
+	void execSelChange(wxTreeItemId item);
+	void setDisplay(pgObject *data, ctlListView *props, ctlSQLBox *sqlbox);
+	void GetExpandedChildNodes(wxTreeItemId node, wxArrayString &expandedNodes);
+	wxString GetNodePath(wxTreeItemId node);
+	void ExpandChildNodes(wxTreeItemId node, wxArrayString &expandedNodes);
+
+	
+	DECLARE_EVENT_TABLE()
+
+private:
+	
+	ctlTree *treectrlsrcdb;
+	ctlTree *treectrltrgdb;
+
+	pgServer *connectedSrcServer;
+	pgServer *connectedTrgServer;
+	pgObject *targetDb;
+	pgObject *sourceDb;
+	
+	wxTreeItemId srcdb;
+	wxTreeItemId trgdb;
+	wxWindow *dlgParent;
+	DiffSystem *diffSys;
+	wxButton *syncBtn;
+	wxButton *diffViewerBtn;
+	wxNotebook *notebook;
+	wxGrid* grid;
+	dlgDiffObjectViewer *dViewer;
+	
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/dlgDiffObjectViewer.h b/pgadmin/include/sv/dlgDiffObjectViewer.h
new file mode 100644
index 0000000..9bc4bef
--- /dev/null
+++ b/pgadmin/include/sv/dlgDiffObjectViewer.h
@@ -0,0 +1,132 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: DiffObjectViewer.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// DiffObjectViewer.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "wx/wx.h"
+#include "wx/image.h"
+#include "wx/xrc/xmlres.h"
+#include "wx/treectrl.h"
+#include "wx/dynarray.h"
+
+
+#ifndef DLG_DIFFOBJVIEWER_H
+#define DLG_DIFFOBJVIEWER_H
+
+
+
+class dlgDbDiff;
+class pgServer;
+class pgDatabase;
+class DiffSystem;
+class ctlListView;
+class ctlSQLBox;
+class DiffObject;
+class TableScript;
+class MappingColObj;
+
+WX_DEFINE_ARRAY_PTR(MappingColObj*, ColMappingArray); 
+
+enum ROW_POS
+{
+	DATATYPE=0,PRIMARYKEY,FOREIGNKEY,NOTNULL,INDEX
+};
+extern ROW_POS rows;
+
+enum COLTYPE
+{
+	COLADD,COLDROP,COLORG
+};
+extern COLTYPE coltype;
+
+class dlgDiffObjectViewer:public pgDialog
+{
+public:
+	dlgDiffObjectViewer(){}
+	dlgDiffObjectViewer(dlgDbDiff *parentDialog);
+	~dlgDiffObjectViewer();
+
+	void Initialize(DiffObject * srcTable,DiffObject * trgTable,TableScript * tabScr);
+
+	void ApplySelChanges(wxCommandEvent& event);
+	void SettingBeforeGrid(size_t srcColCount,size_t trgColCount);
+	void SettingAfterGrid(size_t ColCount);
+	void SetImages();
+	void DialogClose(wxCloseEvent &event);
+	
+	void RenderBeforeDifference();
+	void RenderAfterDifference();
+	void RenderCellDifference();
+	void PopulateBeforeColumns();
+	void PopulateAfterColumns();
+	void RenderColumnsBeforeDiff();
+	void RenderColumnsAfterDiff();
+	void RenderIndexBeforeDiff();
+	
+
+	void SetColBgGreen(int colId,wxGrid * grid);
+	void SetColBgRed(int colId,wxGrid * grid);
+	void SetCellBgYellow(int row,int colId,wxGrid * grid);
+
+	MappingColObj *srcSearchColMap(wxString name);
+	MappingColObj *trgSearchColMap(wxString name);
+	
+	
+	DECLARE_EVENT_TABLE()
+private:
+	wxWindow *dlgParent;
+	wxGrid *sourceObjGrid;
+	wxGrid *targetObjGrid; 
+	wxGrid *targetAfterGrid;
+	DiffObject *srcTable; // not owned
+	DiffObject *trgTable; // not owned
+	TableScript *tableScr; // not owned
+	int ROWS;
+	ColMappingArray srcColMapping;
+	ColMappingArray trgColMapping;
+};
+
+class MappingColObj
+{
+
+public:
+	MappingColObj(){bNotNull=false;bSetPk=false;bSetFk=false;bSetIndex=false;}
+	void SetColName(wxString colName){columnName=colName;}
+	wxString GetColName() const {return columnName;}
+	void SetGridColId(int id){ Id = id;}
+	wxString GetColName(){ return columnName; }
+	int GetGridColId(){ return Id; }
+	void SetNotNull(bool nNull){ bNotNull=nNull; }
+	bool GetNotNull() const { return bNotNull; }
+	void SetPk(bool pk){bSetPk=pk;}
+	bool GetPk() const {return bSetPk;}
+	void SetFk(bool fk){bSetFk=fk;}
+	bool GetFk() const {return bSetFk;}
+	
+	void SetIndex(bool ind){ bSetIndex=ind; }
+	bool IsIndexSet(){return bSetIndex;}
+	
+	void SetDataType(wxString dtype){dataType = dtype;}
+	wxString GetDataType() const {return dataType;}
+	void SetIndexType(wxString indType){indexType = indType;}
+	wxString GetIndexType(){return indexType;}
+	void SetColType(int type){colMetaType = type;}
+	int GetColType(){return colMetaType;}
+
+private:
+	int Id;
+	wxString columnName;
+	bool bNotNull,bSetPk,bSetFk,bSetIndex;
+	wxString dataType;
+	wxString indexType;
+	int colMetaType;
+};
+
+
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/module.mk b/pgadmin/include/sv/module.mk
new file mode 100644
index 0000000..82d2222
--- /dev/null
+++ b/pgadmin/include/sv/module.mk
@@ -0,0 +1,36 @@
+#######################################################################
+#
+# pgAdmin III - PostgreSQL Tools
+# $Id: module.mk 8189 2010-02-25 22:10:21Z dpage $
+# Copyright (C) 2002 - 2009, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# module.mk - pgadmin/include/sv/ Makefile fragment
+#
+#######################################################################
+
+pgadmin3_SOURCES += \
+	$(srcdir)include/sv/dlgAuthServer.h \
+	$(srcdir)include/sv/dlgDbDiff.h \
+	$(srcdir)include/sv/svAddColumn.h \
+	$(srcdir)include/sv/svAddIndex.h \
+	$(srcdir)include/sv/svAddSchema.h \
+	$(srcdir)include/sv/svAddTable.h \
+	$(srcdir)include/sv/svColumnDiff.h \
+	$(srcdir)include/sv/svConstraintDiff.h \
+	$(srcdir)include/sv/svDbDiff.h \
+    $(srcdir)include/sv/svDiffElement.h \
+	$(srcdir)include/sv/svDropColumn.h \
+	$(srcdir)include/sv/svFKDiff.h \
+	$(srcdir)include/sv/svIndexDiff.h \
+	$(srcdir)include/sv/svPKDiff.h \
+	$(srcdir)include/sv/svSchemaDiff.h \
+	$(srcdir)include/sv/svTableDiff.h \
+	$(srcdir)include/sv/svUniqueDiff.h \
+	$(srcdir)include/sv/svViewDiff.h \
+	$(srcdir)include/sv/svDiffObject.h
+
+EXTRA_DIST += \
+    $(srcdir)include/sv/include/module.mk
+
+
diff --git a/pgadmin/include/sv/svAddColumn.h b/pgadmin/include/sv/svAddColumn.h
new file mode 100644
index 0000000..a44f694
--- /dev/null
+++ b/pgadmin/include/sv/svAddColumn.h
@@ -0,0 +1,37 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAddColumn.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAddColumn.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_ADDCOLUMN_H
+#define SV_ADDCOLUMN_H
+
+#include"sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svColumnDiff.h"
+
+
+class pgColumn;
+class DiffObject;
+class ColumnDiff;
+
+class AddColumn:public ColumnElement
+{
+
+public:
+	AddColumn(){}
+	AddColumn(DiffObject *obj);
+	void GenerateScript();
+	
+private:
+	pgColumn *column;
+	int metaType;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svAddFk.h b/pgadmin/include/sv/svAddFk.h
new file mode 100644
index 0000000..fd77f76
--- /dev/null
+++ b/pgadmin/include/sv/svAddFk.h
@@ -0,0 +1,39 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAddFk.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAddFk.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_ADDFK_H
+#define SV_ADDFK_H
+
+#include"sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svColumnDiff.h"
+
+class DiffObject;
+class pgForeignKey;
+
+class AddFk:public FkElement
+{
+
+public:
+	AddFk(){}
+	AddFk(DiffObject *obj);
+	void GenerateScript();
+	void ApplyScript();
+	wxString GetScript(){return sqlScript;}
+
+private:
+	pgForeignKey *fk;
+	//int metaType;
+	wxString sqlScript;
+
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svAddIndex.h b/pgadmin/include/sv/svAddIndex.h
new file mode 100644
index 0000000..a053510
--- /dev/null
+++ b/pgadmin/include/sv/svAddIndex.h
@@ -0,0 +1,37 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAddIndex.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAddIndex.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_ADDINDEX_H
+#define SV_ADDINDEX_H
+
+#include"sv/svDiffElement.h"
+
+class pgIndex;
+class DiffObject;
+
+class AddIndex:public IndexElement
+{
+
+public:
+	AddIndex(){}
+	AddIndex(DiffObject * obj);
+	void GenerateScript();
+	void ApplyScript();
+	//wxString GetScript(){return sqlScript;}
+
+private:
+	pgIndex * index;
+	//int metaType;
+	//wxString sqlScript;
+
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svAddPk.h b/pgadmin/include/sv/svAddPk.h
new file mode 100644
index 0000000..4422e7d
--- /dev/null
+++ b/pgadmin/include/sv/svAddPk.h
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAddPk.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAddPk.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_ADDPK_H
+#define SV_ADDPK_H
+
+#include"sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+//#include "sv/svPkDiff.h"
+
+
+class pgPrimaryKey;
+class DiffObject;
+class PkDiff;
+
+class AddPk:public PkElement
+{
+
+public:
+	AddPk(){}
+	AddPk(DiffObject *obj);
+	void GenerateScript();
+	//void ApplyScript();
+	//wxString GetScript(){return sqlScript;}
+
+private:
+	pgPrimaryKey *pk;
+	//int metaType;
+	//wxString sqlScript;
+
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svAddUnique.h b/pgadmin/include/sv/svAddUnique.h
new file mode 100644
index 0000000..8727b76
--- /dev/null
+++ b/pgadmin/include/sv/svAddUnique.h
@@ -0,0 +1,33 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAddUnique.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAddUnique.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_ADDUNIQUE_H
+#define SV_ADDUNIQUE_H
+
+#include"sv/svDiffElement.h"
+
+class DiffObject;
+class pgUnique;
+
+class AddUnique:public UniqueElement
+{
+
+public:
+	AddUnique(){}
+	AddUnique(DiffObject *obj);
+	void GenerateScript();
+	//void ApplyScript();
+private:
+	pgUnique *unique;
+	//int metaType;
+	//wxString sqlScript;
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svAlterColumn.h b/pgadmin/include/sv/svAlterColumn.h
new file mode 100644
index 0000000..42fb902
--- /dev/null
+++ b/pgadmin/include/sv/svAlterColumn.h
@@ -0,0 +1,45 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterColumn.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterColumn.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_ALTERCOLUMN_H
+#define SV_ALTERCOLUMN_H
+
+#include"sv/svDiffElement.h"
+
+class pgColumn;
+class DiffObject;
+
+class AlterColumn:public ColumnElement
+{
+
+public:
+	AlterColumn(){}
+	AlterColumn(DiffObject *);
+	void GenerateScript();
+	void setTypChange(bool tc){ btypChange=tc;}
+	void setDropNotNull(bool dnn){bdropNotNull=dnn;}
+	void setTypes(wxString srcType,wxString destType);
+	bool IsTypChange(){return btypChange;}
+	wxString GetSrcDataType(){return sourceDataType;}
+	wxString GetDestDataType(){return destinationDataType;}
+	
+	
+
+private:
+	pgColumn *column;
+	bool btypChange;
+	bool bdropNotNull;
+	wxString sourceDataType;
+	wxString destinationDataType;
+	wxString varTypeName;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svAlterFk.h b/pgadmin/include/sv/svAlterFk.h
new file mode 100644
index 0000000..eaf0fab
--- /dev/null
+++ b/pgadmin/include/sv/svAlterFk.h
@@ -0,0 +1,35 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterFk.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterFk.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_ALTERFK_H
+#define SV_ALTERFK_H
+
+#include"sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+
+class pgForeignKey;
+class DiffObject;
+
+class AlterFk:public FkElement
+{
+
+public:
+	AlterFk(){}
+	AlterFk(DiffObject *obj);
+	void GenerateScript();
+	void setAlterCase(wxString c){alterCase=c;}
+
+private:
+	pgForeignKey *fk;
+	wxString alterCase;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svAlterIndex.h b/pgadmin/include/sv/svAlterIndex.h
new file mode 100644
index 0000000..6a6379e
--- /dev/null
+++ b/pgadmin/include/sv/svAlterIndex.h
@@ -0,0 +1,33 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterIndex.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterIndex.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_ALTERINDEX_H
+#define SV_ALTERINDEX_H
+
+#include"sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+
+class pgIndex;
+class DiffObject;
+
+class AlterIndex:public IndexElement
+{
+public:
+	AlterIndex(){}
+	AlterIndex(DiffObject *obj);
+	void GenerateScript();
+	void setAlterCase(wxString c){alterCase=c;}
+
+private:
+	pgIndex *index;
+	wxString alterCase;
+};
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svAlterPk.h b/pgadmin/include/sv/svAlterPk.h
new file mode 100644
index 0000000..20cc2be
--- /dev/null
+++ b/pgadmin/include/sv/svAlterPk.h
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterPk.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterPk.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_ALTERPK_H
+#define SV_ALTERPK_H
+
+#include"sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+
+
+class pgPrimaryKey;
+class DiffObject;
+
+WX_DEFINE_ARRAY_INT(int, AlterPkDepFkArray);
+
+class AlterPk:public PkElement
+{
+
+public:
+	AlterPk(){}
+	AlterPk(DiffObject *obj);
+	void GenerateScript();
+	void setAlterCase(wxString c){alterCase=c;}
+	AlterPkDepFkArray &GetDependentFkList(){ return pkDepFkList; } // ids of dependents fk list
+	void iSetPkDepFkId(int id){ pkDepFkList.Add(id); }
+	bool HasDepFk(){return bPkDepFk;}
+
+private:
+	pgPrimaryKey *pk;
+	wxString alterCase;
+	AlterPkDepFkArray pkDepFkList;
+	bool bPkDepFk;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svAlterSchema.h b/pgadmin/include/sv/svAlterSchema.h
new file mode 100644
index 0000000..f75f865
--- /dev/null
+++ b/pgadmin/include/sv/svAlterSchema.h
@@ -0,0 +1,32 @@
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterSchema.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterSchema.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_ALTERSCHEMA_H
+#define SV_ALTERSCHEMA_H
+
+#include"sv/svDiffElement.h"
+
+class DiffObject;
+class pgSchema;
+class AlterSchema:public SchemaElement
+{
+public:
+	AlterSchema(){}
+	AlterSchema(DiffObject *obj);
+	wxString GetName(){ return schName; }
+	void GenerateScript();
+
+private:
+	pgSchema *schema;
+	wxString schName;
+	//wxString sqlScript;
+	//int metaType;
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svAlterTable.h b/pgadmin/include/sv/svAlterTable.h
new file mode 100644
index 0000000..8a89ebb
--- /dev/null
+++ b/pgadmin/include/sv/svAlterTable.h
@@ -0,0 +1,37 @@
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterTable.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterTable.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_ALTERTABLE_H
+#define SV_ALTERTABLE_H
+
+#include"sv/svDiffElement.h"
+
+class pgTable;
+class DiffObject;
+
+class AlterTable:public TableElement
+{
+
+public:
+	AlterTable(){}
+	AlterTable(DiffObject *obj);
+	wxString GetName(){ return tabName; }
+	void GenerateScript();
+	//wxString GetScript(){ return sqlScript; }
+	//void ApplyScript();
+
+private:
+	pgTable *table;
+	wxString schName;
+	wxString tabName;
+	//wxString sqlScript;
+	//int metaType;
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svAlterUnique.h b/pgadmin/include/sv/svAlterUnique.h
new file mode 100644
index 0000000..8f3d5f7
--- /dev/null
+++ b/pgadmin/include/sv/svAlterUnique.h
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterUnique.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterUnique.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_ALTERUNIQUE_H
+#define SV_ALTERUNIQUE_H
+
+#include"sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+
+class pgUnique;
+class DiffObject;
+
+WX_DEFINE_ARRAY_INT(int, AlterUniqueDepFkArray);
+
+class AlterUnique:public UniqueElement
+{
+public:
+	AlterUnique(){}
+	AlterUnique(DiffObject *obj);
+	void GenerateScript();
+	void setAlterCase(wxString c){alterCase=c;}
+
+	AlterUniqueDepFkArray &GetDependentFkList(){ return uniqueDepFkList; } // ids of dependents fk list
+	void iSetUniqueDepFkId(int id){ uniqueDepFkList.Add(id); }
+	bool HasDepFk(){return bUniqueDepFk;}
+
+
+private:
+	pgUnique *unique;
+	wxString alterCase;
+	AlterUniqueDepFkArray uniqueDepFkList;
+	bool bUniqueDepFk;
+};
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svColumnDiff.h b/pgadmin/include/sv/svColumnDiff.h
new file mode 100644
index 0000000..9a8f7ff
--- /dev/null
+++ b/pgadmin/include/sv/svColumnDiff.h
@@ -0,0 +1,66 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svColumnDiff.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svColumnDiff.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_COLUMNDIFF_H
+#define SV_COLUMNDIFF_H
+
+#include "wx/dynarray.h"
+#include "sv/svDiffObject.h"
+#include "sv/svDiffSystem.h"
+#include "schema/pgColumn.h"
+
+class pgObject;
+class DiffObject;
+class DiffElement;
+class ColumnScript;
+class PkScript;
+class FkScript;
+class UniqueScript;
+class IndexScript;
+
+WX_DEFINE_ARRAY_PTR(ColumnElement*, ColumnDiffArray); // Diff Elements @ table level
+
+
+class ColumnDiff:public DiffObject
+{
+public:
+	ColumnDiff(){}
+	ColumnDiff(pgObject * column):DiffObject(column){	columnhandle = (pgColumn *)column;	}
+	void LoadDiffSystemObjects(wxTreeItemId columnrootId, ctlTree *);
+	bool GenStructuralDiff(DiffObject * trgColumn,ctlTree * src, ctlTree * trg, wxTreeItemId dummyId,ColumnScript * columnScr);
+	void ApplyDiff();
+	pgColumn *GetColumn(){ return columnhandle; }
+
+private:
+	pgColumn * columnhandle;
+};
+
+class ColumnScript
+{
+public:
+	ColumnScript(){}
+	void GenerateScript();
+	wxString GenerateCreateScript(wxString tableName,wxString schemaName);
+	wxString GenerateAlterScript(wxString tableName,wxString schemaName,PkScript*,FkScript*,IndexScript*,UniqueScript*,ViewScript *viewScr,wxString ObjType);
+	wxString GenerateDropScript(wxString tableName,wxString schemaName,PkScript*,FkScript*,IndexScript*,UniqueScript*,ViewScript *viewScr);
+
+	void ApplyScript();
+	void AddDiffElement(ColumnElement * de);
+	bool IsPresent(wxString schemaName);
+	DiffElement *GetElement(wxString schemaName);
+	ColumnDiffArray GetColumnList(){return columnDiffList;}
+	
+private:
+	ColumnDiffArray columnDiffList; 
+
+};
+
+#endif
diff --git a/pgadmin/include/sv/svCreateColumn.h b/pgadmin/include/sv/svCreateColumn.h
new file mode 100644
index 0000000..4daef09
--- /dev/null
+++ b/pgadmin/include/sv/svCreateColumn.h
@@ -0,0 +1,35 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateColumn.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateColumn.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_CREATECOLUMN_H
+#define SV_CREATECOLUMN_H
+
+#include"sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+
+class pgColumn;
+class DiffObject;
+
+class CreateColumn:public ColumnElement
+{
+
+public:
+	CreateColumn(){}
+	CreateColumn(DiffObject *obj);
+	void GenerateScript();
+	//void ApplyScript();
+private:
+	pgColumn *column;
+	//int metaType;
+	//wxString sqlScript;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svCreateFk.h b/pgadmin/include/sv/svCreateFk.h
new file mode 100644
index 0000000..565e7b4
--- /dev/null
+++ b/pgadmin/include/sv/svCreateFk.h
@@ -0,0 +1,37 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAddFk.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAddFk.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_CREATEFK_H
+#define SV_CREATEFK_H
+
+#include"sv/svDiffElement.h"
+
+class pgForeignKey;
+class DiffObject;
+
+class CreateFk:public FkElement
+{
+
+public:
+	CreateFk(){}
+	CreateFk(DiffObject *obj);
+	void GenerateScript();
+	//void ApplyScript();
+	//wxString GetScript(){return sqlScript;}
+
+private:
+	pgForeignKey *fk;
+	//int metaType;
+	//wxString sqlScript;
+	
+
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svCreateIndex.h b/pgadmin/include/sv/svCreateIndex.h
new file mode 100644
index 0000000..0b8c901
--- /dev/null
+++ b/pgadmin/include/sv/svCreateIndex.h
@@ -0,0 +1,37 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateIndex.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateIndex.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_CREATEINDEX_H
+#define SV_CREATEINDEX_H
+
+#include"sv/svDiffElement.h"
+
+class pgIndex;
+class DiffObject;
+
+class CreateIndex:public IndexElement
+{
+
+public:
+	CreateIndex(){}
+	CreateIndex(DiffObject * obj);
+	void GenerateScript();
+	void ApplyScript();
+	//wxString GetScript(){return sqlScript;}
+
+private:
+	pgIndex * index;
+	//int metaType;
+	//wxString sqlScript;
+
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svCreatePk.h b/pgadmin/include/sv/svCreatePk.h
new file mode 100644
index 0000000..2a516ee
--- /dev/null
+++ b/pgadmin/include/sv/svCreatePk.h
@@ -0,0 +1,35 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreatePk.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreatePk.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_CREATEPK_H
+#define SV_CREATEPK_H
+
+#include"sv/svDiffElement.h"
+
+class DiffObject;
+class pgPrimaryKey;
+
+class CreatePk:public PkElement
+{
+
+public:
+	CreatePk(){}
+	CreatePk(DiffObject *obj);
+	void GenerateScript();
+	void ApplyScript();
+	//wxString GetScript(){return sqlScript;}
+private:
+	pgPrimaryKey *pk;
+	//int metaType;
+	//wxString sqlScript;
+
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svCreateRule.h b/pgadmin/include/sv/svCreateRule.h
new file mode 100644
index 0000000..92a0d20
--- /dev/null
+++ b/pgadmin/include/sv/svCreateRule.h
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateRule.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateRule.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_CREATERULE_H
+#define SV_CREATERULE_H
+
+#include"sv/svDiffElement.h"
+
+class DiffObject;
+class pgRule;
+
+class CreateRule:public RuleElement
+{
+
+public:
+	CreateRule(){}
+	CreateRule(DiffObject *obj);
+	void GenerateScript();
+private:
+	pgRule *rule;
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svCreateSchema.h b/pgadmin/include/sv/svCreateSchema.h
new file mode 100644
index 0000000..316bb39
--- /dev/null
+++ b/pgadmin/include/sv/svCreateSchema.h
@@ -0,0 +1,39 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateSchema.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateSchema.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_CREATESCHEMA_H
+#define SV_CREATESCHEMA_H
+
+#include"sv/svDiffElement.h"
+#include "sv/svSchemaDiff.h"
+#include "sv/svDiffSystem.h"
+
+class pgSchema;
+class DiffObject;
+class SchemaDiff;
+
+class CreateSchema:public SchemaElement
+{
+
+public:
+	CreateSchema(){}
+	CreateSchema(DiffObject * obj);
+	void GenerateScript();
+	void ApplyScript();
+	//wxString GetScript(){return sqlScript;}
+private:
+	pgSchema * sch;
+	wxString schName;
+//	int metaType;
+	//wxString sqlScript;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svCreateTable.h b/pgadmin/include/sv/svCreateTable.h
new file mode 100644
index 0000000..6a03910
--- /dev/null
+++ b/pgadmin/include/sv/svCreateTable.h
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateTable.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateTable.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_CREATETABLE_H
+#define SV_CREATETABLE_H
+
+#include"sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svTableDiff.h"
+
+class pgTable;
+class DiffObject;
+
+class CreateTable:public TableElement
+{
+
+public:
+	CreateTable(){}
+	CreateTable(DiffObject * obj);
+	void GenerateScript();
+	void ApplyScript();
+	//wxString GetSchemaName(){ return schemaName;}
+	//wxString GetScript(){return sqlScript;}
+
+private:
+	pgTable *table;
+	wxString tableName;
+	wxString schemaName;
+	//int metaType;
+	//wxString sqlScript;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svCreateUnique.h b/pgadmin/include/sv/svCreateUnique.h
new file mode 100644
index 0000000..84d6ea6
--- /dev/null
+++ b/pgadmin/include/sv/svCreateUnique.h
@@ -0,0 +1,33 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateUnique.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateUnique.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_CREATEUNIQUE_H
+#define SV_CREATEUNIQUE_H
+
+#include"sv/svDiffElement.h"
+
+class DiffObject;
+class pgUnique;
+
+class CreateUnique:public UniqueElement
+{
+
+public:
+	CreateUnique(){}
+	CreateUnique(DiffObject *obj);
+	void GenerateScript();
+	//void ApplyScript();
+private:
+	pgUnique *unique;
+	//int metaType;
+	//wxString sqlScript;
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svCreateView.h b/pgadmin/include/sv/svCreateView.h
new file mode 100644
index 0000000..1b85e93
--- /dev/null
+++ b/pgadmin/include/sv/svCreateView.h
@@ -0,0 +1,34 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateView.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateView.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_CREATEVIEW_H
+#define SV_CREATEVIEW_H
+
+#include"sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svViewDiff.h"
+
+class pgView;
+class DiffObject;
+
+class CreateView:public ViewElement
+{
+
+public:
+	CreateView(){}
+	CreateView(DiffObject * obj);
+	void GenerateScript();
+	
+private:
+	pgView *view;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svDbDiff.h b/pgadmin/include/sv/svDbDiff.h
new file mode 100644
index 0000000..31877db
--- /dev/null
+++ b/pgadmin/include/sv/svDbDiff.h
@@ -0,0 +1,78 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDbDiff.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDbDiff.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_DBDIFF
+#define SV_DBDIFF
+
+#include "wx/dynarray.h"
+#include "sv/svDiffObject.h"
+#include "sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+
+
+class pgObject;
+class pgDatabase;
+class DiffObject;
+class DiffElement;
+class ctlTree;
+class DiffSystem;
+class SchemaDiff;
+class DbScript;
+class SchemaScript;
+class ScriptSys;
+
+
+WX_DEFINE_ARRAY_PTR(DiffObject*, DatabaseObjArray); // holds objects under database
+WX_DEFINE_ARRAY_PTR(DiffElement*, DatabaseObjDiffArray); // Diff Elements @ db level
+
+class DbDiff:public DiffObject
+{
+public:
+	DbDiff(){schemaHasChanges=false;}
+	DbDiff(pgDatabase * db);
+	void LoadDiffSystemObjects(wxTreeItemId databaserootId, ctlTree *);
+	void GenStructuralDiff(DiffObject * trg,ctlTree * srcTree , ctlTree * trgTree,wxTreeItemId dummyId,DbScript *dbScript);
+	void ApplyDiff();
+	SchemaDiff *FindObj(wxString );
+	bool IsPresent(wxString);
+	DatabaseObjArray& GetSchemaList(){ return objlist; }
+
+private:
+	pgDatabase * dbhandle;
+	DatabaseObjArray objlist;
+	DbScript *dbscript;
+	int meta_type;
+	bool schemaHasChanges;
+};
+
+
+class DbScript
+{
+public:
+	DbScript(){}
+	void Initialize();
+	void GenerateScript();
+	wxString GenerateCreateScript();
+	wxString GenerateAlterScript();
+	wxString GenerateDropScript();
+	wxString GenerateFkScripts();
+
+	void ApplyScript();
+	void AddDiffElement(DiffElement * de);
+	bool IsPresent(wxString schemaName);
+	DiffElement *GetElement(wxString schemaName);
+	SchemaScript *GetSchemaScriptHandle(){ return schemaScript; }
+private:
+	DatabaseObjDiffArray DiffList;  // probably would be schema at this place only
+	SchemaScript *schemaScript;
+};
+
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svDiffElement.h b/pgadmin/include/sv/svDiffElement.h
new file mode 100644
index 0000000..be321b8
--- /dev/null
+++ b/pgadmin/include/sv/svDiffElement.h
@@ -0,0 +1,149 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDiffElement.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDiffElement.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_DIFFELEMENT
+#define SV_DIFFELEMENT
+
+
+class DiffElement
+{
+public:
+	DiffElement(){	applied=false;	}
+	void GenerateScript(){}
+	int GetMetaType(){return metaType;}
+	void SetMetaType(int mtype){metaType = mtype;}
+	wxString GetScript()
+	{
+		applied=true;
+		return sqlScript;
+	}
+	void SetScript(wxString script){sqlScript = script;}
+
+	bool IsAlreadyApplied()
+	{
+		if(applied)
+			return true;
+		else
+			return false;
+	}
+	void SetApplied(bool f){applied=f;}
+
+private:
+	bool applied;
+	int metaType;
+	wxString sqlScript;
+};
+
+class SchemaElement:public DiffElement
+{
+public:
+	SchemaElement(){}
+	void SetSchemaName(wxString name){schemaName = name;}
+	wxString GetSchemaName(){return schemaName;}
+private:
+	wxString schemaName;
+};
+class TableElement:public virtual SchemaElement
+{
+public:
+	TableElement(){}
+	void SetTableName(wxString name){tableName = name;}
+	wxString GetTableName(){return tableName;}
+	
+private:
+	wxString tableName;
+};
+class ViewElement:public virtual SchemaElement
+{
+public:
+	ViewElement(){}
+	void SetViewName(wxString name){viewName = name;}
+	wxString GetViewName(){return viewName;}
+	
+	
+private:
+	wxString viewName;
+};
+class RuleElement:public ViewElement
+{
+public:
+	RuleElement(){}
+	void SetRuleName(wxString name){ruleName = name;}
+	wxString GetRuleName(){return ruleName;}
+	
+private:
+	wxString ruleName;
+};
+class ColumnElement:public TableElement,public ViewElement
+{
+public:
+	ColumnElement(){}
+	void SetColumnName(wxString name){ columnName = name; }
+	wxString GetColumnName() const { return columnName; }
+	void SetVarTypeName(wxString typName){ varTypeName=typName; }
+	wxString GetVarTypeName() const { return varTypeName; }
+	bool GetIsPK() const {return isPK; }
+    bool GetIsFK() const {return isFK; }
+	void SetIsPK(bool pk) { isPK = pk; }
+	void SetIsFK(bool fk) { isFK = fk; }
+	bool GetNotNull() const {return notNull; }
+	void SetNotNull(bool nNull){ notNull=nNull; }
+	
+private:
+	wxString columnName;
+	wxString varTypeName;
+	bool isPK,isFK,notNull;
+	
+};
+class IndexElement:public TableElement
+{
+public:
+	IndexElement(){}
+	void SetIndexName(wxString name){indexName = name;}
+	wxString GetIndexName(){return indexName;}
+
+private:
+	wxString indexName;
+};
+class PkElement:public TableElement
+{
+public:
+	PkElement(){}
+	void SetPkName(wxString name){pkName = name;}
+	wxString GetPkName(){return pkName;}
+
+private:
+	wxString pkName;
+};
+class FkElement:public TableElement
+{
+public:
+	FkElement(){}
+	void SetFkName(wxString name){fkName = name;}
+	wxString GetFkName(){return fkName;}
+
+private:
+	wxString fkName;
+};
+class UniqueElement:public virtual TableElement
+{
+public:
+	UniqueElement(){}
+	void SetUniqueName(wxString name){uniqueName = name;}
+	wxString GetUniqueName(){return uniqueName;}
+
+private:
+	wxString uniqueName;
+};
+
+
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svDiffObject.h b/pgadmin/include/sv/svDiffObject.h
new file mode 100644
index 0000000..8d2e70f
--- /dev/null
+++ b/pgadmin/include/sv/svDiffObject.h
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDiffObject.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDiffObject.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_DIFFOBJ
+#define SV_DIFFOBJ
+
+#include "wx/dynarray.h"
+
+#include "schema/pgObject.h"
+
+class DependentObjArray;
+
+
+class DiffObject
+{
+public:
+	DiffObject(){}
+	DiffObject(pgObject *aobj) { objhandle = aobj; }
+	pgObject * GetObject() { return objhandle; }
+	int GetMetaType() {	return objhandle->GetMetaType(); }
+	
+	virtual bool GenStructuralDiff(DiffObject * tar,ctlTree * srcTree, ctlTree * trgTree,wxTreeItemId dummyId) { return true; }
+	static void FetchDep(pgObject * obj,const wxString query, const wxString &clsorder,DependentObjArray &depList);
+	static void GetDependents(pgObject * obj,DependentObjArray &depList,const wxString &wh);
+	
+private:
+	pgObject *objhandle;
+	bool applied;
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svDiffSystem.h b/pgadmin/include/sv/svDiffSystem.h
new file mode 100644
index 0000000..42e2264
--- /dev/null
+++ b/pgadmin/include/sv/svDiffSystem.h
@@ -0,0 +1,165 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDiffSystem.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDiffSystem.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef SV_DIFF_SYS_H
+#define SV_DIFF_SYS_H
+
+#include "wx/wx.h"
+#include "wx/image.h"
+#include "wx/file.h"
+#include "wx/grid.h"
+#include "sv/svDbDiff.h"
+#include "sv/svSchemaDiff.h"
+#include "sv/svTableDiff.h"
+#include "sv/svViewDiff.h"
+
+
+class pgDatabase;
+class wxTreeItemId;
+class ctlTree;
+class DbDiff;
+class DbScript;
+class SchemaScript;
+class TableScript;
+class ViewScript;
+class ScriptSys;
+class pgObject;
+
+class DiffImages
+{
+public:
+    int IMG_DB_CHG;	int IMG_SCH_CHG;int IMG_SCH_PRES;int IMG_SCH_MISS;
+	
+	int IMG_TABLE_CHG;int IMG_TABLE_PRES;int IMG_TABLE_MISS;
+	int IMG_VIEW_CHG;int IMG_VIEW_PRES;int IMG_VIEW_MISS;
+	int IMG_COLUMN_CHG;int IMG_COLUMN_PRES;int IMG_COLUMN_MISS;
+	int IMG_INDEX_CHG;int IMG_INDEX_PRES;int IMG_INDEX_MISS;
+	int IMG_PK_CHG;int IMG_PK_PRES;int IMG_PK_MISS;
+	int IMG_FK_CHG;int IMG_FK_PRES;	int IMG_FK_MISS;
+	int IMG_UNIQUE_CHG;	int IMG_UNIQUE_PRES; int IMG_UNIQUE_MISS;
+	int IMG_RULE_CHG; int IMG_RULE_PRES; int IMG_RULE_MISS;
+
+	// collection images
+	int IMG_SCHEMAS_CHG;	int IMG_TABLES_CHG;	int IMG_VIEWS_CHG;	int IMG_COLUMNS_CHG;
+	int IMG_INDEXES_CHG;	int IMG_RULES_CHG;	int IMG_CONSTRAINTS_CHG; int IMG_SCHEMAS;
+	int IMG_TABLES;     	int IMG_VIEWS;  	int IMG_COLUMNS;	int IMG_INDEXES;
+	//int IMG_RULES_CHG;
+	int IMG_CONSTRAINTS;
+};
+extern DiffImages svImages;
+
+enum DiffElements
+{
+	/* ALTERSCHEMA not generates any script for now, used only to track ALTER elements
+	under it and doesnt changes the schema itself, but it depends upon what level of difference one caters, 
+	 it could be used in future to make added changes of atleast schema ownership*/
+	ALTERSCHEMA, 
+
+	CRTSCHEMA,CRTTABLE,CRTCOLUMN,CRTINDEX,CRTUNIQUE,CRTFK,CRTPK, // on creation
+	CRTVIEW,CRTRULE,
+	
+	ADDCOLUMN,ADDFK,ADDPK,ADDINDEX,ADDUNIQUE,  // change existing
+	ADDRULE,
+
+	/* ALTERTABLE not generates any script for now, used only to track ALTER elements
+	under it and doesnt changes the table itself*/
+	
+	ALTERTABLE,ALTERCOLUMN,  // change existing
+	ALTERVIEW,
+
+	// all of these are used to just copy source obj-destination(one way),
+	ALTERPK,ALTERFK,ALTERINDEX,ALTERUNIQUE,
+
+	DROPSCHEMA,DROPTABLE,DROPCOLUMN,DROPINDEX,DROPUNIQUE,DROPFK,DROPPK, // dropping stuff
+	
+	DROPVIEW,DROPRULE
+	
+};
+extern DiffElements diffElem;
+
+class DiffSystem
+{
+	
+public:
+	DiffSystem(){diffTaken=false;}
+	void Initialize(ctlTree *,ctlTree *);
+	void SetDatabase(pgDatabase *srcdb,pgDatabase *trgdb);
+	void GenSrcDiff(wxTreeItemId id);
+	bool ApplyDiff();
+	bool IsDiffTaken(){return diffTaken;}
+	void SetDiffTaken(bool dt){diffTaken=dt;}
+	bool IsSync(){return bSync;}
+	bool IsDiffExist();
+	
+	bool ShowDiffGrid(pgObject *obj,wxGrid * grid);
+	DiffObject *GetSrcTableObject(wxString schName,wxString tabName);
+	DiffObject *GetTrgTableObject(wxString schName,wxString tabName);
+	TableScript *GetTableScriptHandle();
+
+	ctlTree *GetSourceTree();
+	ctlTree *GetTargetTree();
+	void LoadDiffSystemImages();
+	
+private:
+	pgDatabase * srcdb;
+	pgDatabase * trgdb;
+	DbDiff * diffsrc;
+	DbDiff * difftrg;
+	ctlTree *sourcetree;
+	ctlTree *targettree;
+	ScriptSys *scrSys;
+	bool diffTaken;
+	wxString diffScript;
+	bool bSync;
+};
+
+class ScriptSys
+{
+public:
+	ScriptSys(){scrCompiled=false;}
+	void Initialize(pgDatabase *target);
+	
+	wxString CompileScript();
+	wxString GenerateCreateScripts();
+	wxString GenerateAlterScripts();
+	wxString GenerateDropScripts();
+	wxString GenerateFkScripts();
+
+	bool ShowDiff(pgObject * selObj, wxGrid * grid,bool bSync);
+	TableScript *GetTableScriptHandle();
+
+	void SetScriptCompiled(bool sc){ scrCompiled = sc;}
+	bool ApplyScript(wxString diffScript);
+	bool IsCompiled(){return scrCompiled;}
+
+	wxString RemoveCarriageRet(wxString str);
+	DbScript *GetDbScript(){return dbScript;}
+	
+private:
+	pgDatabase *trgDb; 
+	DbScript *dbScript;
+	bool scrCompiled;
+};
+
+class DependencyObj
+{
+public:
+	wxString schemaName; // depend obj schema
+	wxString tableName;  // depedent obj table
+	wxString objName;    // dependent obj name
+	wxString objTypeName;    // dependent obj type  fk,unique,index,
+};
+
+
+#endif
+
+
diff --git a/pgadmin/include/sv/svDropColumn.h b/pgadmin/include/sv/svDropColumn.h
new file mode 100644
index 0000000..221b331
--- /dev/null
+++ b/pgadmin/include/sv/svDropColumn.h
@@ -0,0 +1,75 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropColumn.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropColumn.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_DROPCOLUMN_H
+#define SV_DROPCOLUMN_H
+
+#include"sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svColumnDiff.h"
+
+
+WX_DEFINE_ARRAY_INT(int, colDepIndexArray); // holds the column index dependents ids
+WX_DEFINE_ARRAY_INT(int, colDepFkArray); // holds the pk dependents ids
+WX_DEFINE_ARRAY_INT(int, colDepViewArray); // holds the pk dependents ids
+
+class pgColumn;
+class DiffObject;
+
+class DropColumn:public ColumnElement
+{
+
+public:
+	DropColumn(){}
+	DropColumn(DiffObject * obj);
+	wxString GetName(){return colName;}
+	void GenerateScript();
+	wxString GetScript(){return script;}
+	void ApplyScript();
+	
+	colDepIndexArray &GetDependentIndexList(){ return colDepIndexList; } // return the ids of dependents indexes
+	colDepFkArray &GetDependentFkList(){ return colDepFkList; } // return the ids of dependents fk
+	colDepViewArray &GetDependentViewList(){ return colDepViewList; } // return the ids of dependents views
+	
+	bool HasIndexDep(){	return bColDepIndex;}
+	bool HasFkDep(){return bColDepFk;}
+	bool HasPkDep(){return bColDepPk;}
+	bool HasUniqueDep(){return bColDepUnique;}
+	bool HasViewDep(){return bColDepView;}
+
+	void iSetColDepIndexId(int id){ colDepIndexList.Add(id); bColDepIndex=true;}
+	void iSetColDepUniqueId(int id){ colUniqueDepId = id; bColDepUnique=true;}
+	void iSetColDepPkId(int id){ colDepPkId = id; bColDepPk=true;}
+	void iSetColDepFkId(int id){ colDepFkList.Add(id); bColDepFk=true;}
+	void iSetColDepViewId(int id){ colDepViewList.Add(id); bColDepView=true;}
+
+	int GetColDepUniqueId(){ return colUniqueDepId; }
+	int GetColDepPkId(){ return colDepPkId; }
+
+	
+
+private:
+	pgColumn * column;
+	wxString colName;
+	wxString tabName;
+	wxString script;
+
+	colDepFkArray colDepFkList; // dependent fk
+	int colDepPkId; // dependent pk
+	int colUniqueDepId; // unique constraint dependent
+	
+	colDepIndexArray colDepIndexList; // dependent indexes
+	colDepViewArray colDepViewList; // dependent views
+
+	bool bColDepIndex,bColDepFk,bColDepPk,bColDepUnique,bColDepView;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svDropFk.h b/pgadmin/include/sv/svDropFk.h
new file mode 100644
index 0000000..f12ab03
--- /dev/null
+++ b/pgadmin/include/sv/svDropFk.h
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropFk.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropFk.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_DROPFK_H
+#define SV_DROPFK_H
+
+#include"sv/svDiffElement.h"
+
+class pgForeignKey;
+class DiffObject;
+
+class DropFk:public FkElement
+{
+
+public:
+	DropFk(){}
+	DropFk(DiffObject * obj);
+	DropFk(wxString tableName,wxString objName,wxString schemaName);
+
+	wxString GetName(){return fkName;}
+	void GenerateScript();
+	//wxString GetScript(){return script;}
+	void ApplyScript();
+private:
+	pgForeignKey *fk;
+	wxString fkName;
+	wxString tabName;
+	wxString colName;
+	wxString sqlScript;
+	
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svDropIndex.h b/pgadmin/include/sv/svDropIndex.h
new file mode 100644
index 0000000..f36d4ee
--- /dev/null
+++ b/pgadmin/include/sv/svDropIndex.h
@@ -0,0 +1,37 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropIndex.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropIndex.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_DROPINDEX_H
+#define SV_DROPINDEX_H
+
+#include"sv/svDiffElement.h"
+
+class DiffObject;
+class pgIndex;
+class DropIndex:public IndexElement
+{
+
+public:
+	DropIndex(){}
+	DropIndex(DiffObject * obj);
+	DropIndex(wxString tableName,wxString objName,wxString schemaName);
+
+	wxString GetName(){return indName;}
+	void GenerateScript();
+	
+private:
+	pgIndex *index;
+	wxString indName;
+	wxString tabName;
+	wxString colName;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svDropPk.h b/pgadmin/include/sv/svDropPk.h
new file mode 100644
index 0000000..3d99f4d
--- /dev/null
+++ b/pgadmin/include/sv/svDropPk.h
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropPk.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropPk.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_DROPPK_H
+#define SV_DROPPK_H
+
+#include"sv/svDiffElement.h"
+
+WX_DEFINE_ARRAY_INT(int, PkDepFkArray); // holds the pk dependents ids
+
+class DiffObject;
+class pgPrimaryKey;
+
+class DropPk:public PkElement
+{
+
+public:
+	DropPk(){}
+	DropPk(DiffObject *);
+	DropPk(wxString tableName,wxString objName,wxString schemaName);
+	
+	wxString GetName(){return pkName;}
+	void GenerateScript();
+	
+
+	PkDepFkArray &GetDependentFkList(){ return pkDepFkList; } // ids of dependents fk list
+	void iSetPkDepFkId(int id){ pkDepFkList.Add(id); }
+	bool HasDepFk(){return bPkDepFk;}
+	
+private:
+	pgPrimaryKey *pk;
+	wxString pkName;
+	wxString tabName;
+	wxString colName;
+	
+	PkDepFkArray pkDepFkList; // foreign keys dependent on this key
+	bool bPkDepFk;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svDropRule.h b/pgadmin/include/sv/svDropRule.h
new file mode 100644
index 0000000..5d2c8ca
--- /dev/null
+++ b/pgadmin/include/sv/svDropRule.h
@@ -0,0 +1,36 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropRule.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropRule.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_DROPRULE_H
+#define SV_DROPRULE_H
+
+#include"sv/svDiffElement.h"
+
+
+class DiffObject;
+class pgRule;
+
+class DropRule:public RuleElement
+{
+
+public:
+	DropRule(){}
+	DropRule(DiffObject *);
+	DropRule(wxString tableName,wxString objName,wxString schemaName);
+	
+	void GenerateScript();
+	
+	
+private:
+	pgRule *rule;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svDropSchema.h b/pgadmin/include/sv/svDropSchema.h
new file mode 100644
index 0000000..fe1237b
--- /dev/null
+++ b/pgadmin/include/sv/svDropSchema.h
@@ -0,0 +1,31 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropSchema.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropSchema.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_DROPSCHEMA_H
+#define SV_DROPSCHEMA_H
+
+#include"sv/svDiffElement.h"
+
+class DiffObject;
+class pgSchema;
+class DropSchema:public SchemaElement
+{
+
+public:
+	DropSchema(){}
+	DropSchema(DiffObject *);
+	void GenerateScript();
+private:
+	pgSchema * schema;
+	wxString schName;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svDropTable.h b/pgadmin/include/sv/svDropTable.h
new file mode 100644
index 0000000..4ee477b
--- /dev/null
+++ b/pgadmin/include/sv/svDropTable.h
@@ -0,0 +1,36 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropTable.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropTable.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_DROPTABLE_H
+#define SV_DROPTABLE_H
+
+#include"sv/svDiffElement.h"
+
+class DiffObject;
+class pgTable;
+class DropTable:public TableElement
+{
+
+public:
+	DropTable(){}
+	DropTable(DiffObject * obj);
+	void GenerateScript();
+	
+
+private:
+	pgTable * table;
+	wxString tabName;
+	wxString schName;
+	//wxString script;
+	//int metaType;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svDropUnique.h b/pgadmin/include/sv/svDropUnique.h
new file mode 100644
index 0000000..14d31b9
--- /dev/null
+++ b/pgadmin/include/sv/svDropUnique.h
@@ -0,0 +1,51 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropUnique.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropUnique.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_DROPUNIQUE_H
+#define SV_DROPUNIQUE_H
+
+#include "sv/svDiffElement.h"
+
+class DiffObject;
+class pgTable;
+class FkDiff;
+class FkScript;
+class pgUnique;
+
+WX_DEFINE_ARRAY_INT(int, UniqueDepFkArray); // holds the unique dependents ids
+
+class DropUnique:public UniqueElement
+{
+
+public:
+	DropUnique(){}
+	DropUnique(DiffObject *);
+	DropUnique(wxString tableName,wxString objName,wxString schemaName);
+
+	wxString GetName(){return uniName;}
+	void GenerateScript();
+	
+	UniqueDepFkArray &GetDependentFkList(){ return uniqueDepFkList; } // ids of dependents fk list
+	void iSetUniqueDepFkId(int id){ uniqueDepFkList.Add(id); };
+	bool HasDepFk(){return bUniqueDepFk;}
+
+private:
+	pgUnique * unique;
+	wxString uniName;
+	wxString tabName;
+	wxString colName;
+
+	UniqueDepFkArray uniqueDepFkList;
+	bool bUniqueDepFk;
+
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svDropView.h b/pgadmin/include/sv/svDropView.h
new file mode 100644
index 0000000..92d9aa5
--- /dev/null
+++ b/pgadmin/include/sv/svDropView.h
@@ -0,0 +1,32 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropView.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropView.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_DROPVIEW_H
+#define SV_DROPVIEW_H
+
+#include"sv/svDiffElement.h"
+
+class DiffObject;
+class pgView;
+class DropView:public ViewElement
+{
+
+public:
+	DropView(){}
+	DropView(DiffObject * obj);
+	DropView(wxString viewName,wxString schemaName);
+	void GenerateScript();
+
+private:
+	pgView * view;
+};
+
+#endif;
\ No newline at end of file
diff --git a/pgadmin/include/sv/svFKDiff.h b/pgadmin/include/sv/svFKDiff.h
new file mode 100644
index 0000000..1d408c0
--- /dev/null
+++ b/pgadmin/include/sv/svFKDiff.h
@@ -0,0 +1,63 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svFkDiff.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svFkDiff.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_FK_DIFF
+#define SV_FK_DIFF
+
+#include "wx/dynarray.h"
+#include "sv/svDiffObject.h"
+#include "sv/svDiffElement.h"
+
+class pgObject;
+class DiffObject;
+class DiffElement;
+class pgForeignKey;
+class FkScript;
+
+WX_DEFINE_ARRAY_PTR(FkElement*, FkDiffArray); // Diff Elements @ table level
+
+class FkDiff:public DiffObject
+{
+public:
+	FkDiff(){}
+	FkDiff(pgObject * cons):DiffObject(cons){	fkchandle = (pgForeignKey *)cons; }
+	bool GenStructuralDiff(DiffObject * trgPk,ctlTree * src, ctlTree * trg,wxTreeItemId dummyId,FkScript * fkScr);
+	void ApplyDiff();
+	pgForeignKey *GetFk(){ return fkchandle; }
+	static void DropFkObject(DiffObject * trgFk, ctlTree* src,ctlTree* trg);
+
+
+private:
+	pgForeignKey *fkchandle;
+	FkScript *fkscript;
+};
+class FkScript
+{
+public:
+	FkScript(){}
+	void GenerateScript();
+	wxString GenerateCreateScript(wxString tableName,wxString schemaName);
+	wxString GenerateAlterScript(wxString &tableName,wxString &schemaName,wxString ObjType);
+	wxString GenerateDropScript(wxString tableName,wxString schemaName);
+
+	void ApplyScript();
+	void AddDiffElement(FkElement * de);
+	bool IsPresent(wxString schemaName);
+	DiffElement *GetElement(wxString schemaName);
+
+	int SearchObject(wxString tableName,wxString objName,int metaType,wxString schemaName);
+	FkDiffArray &GetFkList(){return fkDiffList;}
+private:
+	FkDiffArray fkDiffList; 
+	
+};
+
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svIndexDiff.h b/pgadmin/include/sv/svIndexDiff.h
new file mode 100644
index 0000000..fe3ff06
--- /dev/null
+++ b/pgadmin/include/sv/svIndexDiff.h
@@ -0,0 +1,63 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svIndexDiff.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svIndexDiff.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_INDEXDIFF
+#define SV_INDEXDIFF
+
+#include "wx/dynarray.h"
+#include "sv/svDiffObject.h"
+#include "sv/svDiffElement.h"
+
+class pgObject;
+class DiffObject;
+class DiffElement;
+class pgIndex;
+class ctlTree;
+class IndexScript;
+
+WX_DEFINE_ARRAY_PTR(IndexElement*, IndexDiffArray); // Diff Elements @ index level
+
+
+class IndexDiff:public DiffObject
+{
+public:
+	IndexDiff(){}
+	IndexDiff(pgObject * index):DiffObject(index){	indexhandle = (pgIndex *)index;	}
+	
+	bool GenStructuralDiff(DiffObject * trgIndex,ctlTree* src, ctlTree * trg,wxTreeItemId dummyId,IndexScript * indexScr);
+	void ApplyDiff();
+	IndexDiff *FindElement();
+	pgIndex *GetIndex(){ return indexhandle; }
+	static void DropIndexObject(DiffObject * trgIndex, ctlTree* src,ctlTree *trg);
+
+
+private:
+	pgIndex * indexhandle;
+	IndexScript *indscript;
+};
+class IndexScript
+{
+public:
+	IndexScript(){}
+	void GenerateScript();
+	wxString GenerateCreateScript(wxString tableName,wxString schemaName);
+	wxString GenerateAlterScript(wxString tableName,wxString schemaName,wxString ObjType);
+	wxString GenerateDropScript(wxString tableName,wxString schemaName);
+	//void ApplyScript();
+	void AddDiffElement(IndexElement * de);
+	bool IsPresent(wxString schemaName);
+	DiffElement *GetElement(wxString schemaName);
+	int SearchObject(wxString tableName,wxString objName,int metaType,wxString schemaName);
+	IndexDiffArray &GetIndexList(){return indexDiffList;}
+private:
+	IndexDiffArray indexDiffList; 
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svPKDiff.h b/pgadmin/include/sv/svPKDiff.h
new file mode 100644
index 0000000..f08681d
--- /dev/null
+++ b/pgadmin/include/sv/svPKDiff.h
@@ -0,0 +1,64 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svPKDiff.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svPKDiff.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_PK_DIFF
+#define SV_PK_DIFF
+
+#include "wx/dynarray.h"
+#include "sv/svDiffObject.h"
+#include "sv/svDiffElement.h"
+#include "sv/svTableDiff.h"
+
+
+class pgObject;
+class DiffObject;
+class DiffElement;
+class pgPrimaryKey;
+class PkScript;
+class FkScript;
+
+WX_DEFINE_ARRAY_PTR(PkElement*, PkDiffArray); // Diff Elements @ constraint level
+
+class PkDiff:public DiffObject
+{
+public:
+	PkDiff(){}
+	PkDiff(pgObject * cons):DiffObject(cons){ pkchandle = (pgPrimaryKey *)cons; }
+	bool GenStructuralDiff(DiffObject * trgPk,ctlTree * src, ctlTree * trg,wxTreeItemId dummyId,TableScript *tabScr);
+	void ApplyDiff();
+	pgPrimaryKey *GetPk(){ return pkchandle; }
+	wxString RemoveQuotes(wxString str);
+
+private:
+	pgPrimaryKey *pkchandle;
+	PkScript *pkscript;
+};
+
+class PkScript
+{
+public:
+	PkScript(){}
+	void GenerateScript();
+	wxString GenerateCreateScript(wxString tableName,wxString schemaName);
+	wxString GenerateAlterScript(wxString tableName,wxString schemaName,FkScript* fkScr,wxString ObjType);
+	wxString GenerateDropScript(wxString tableName,wxString schemaName,FkScript* fkScr);
+	int SearchObject(wxString tableName,wxString objName,int metaType,wxString schemaName);
+
+	void ApplyScript();
+	void AddDiffElement(PkElement * de);
+	bool IsPresent(wxString schemaName);
+	DiffElement *GetElement(wxString schemaName);
+	PkDiffArray &GetPkList(){return pkDiffList;}
+private:
+	PkDiffArray pkDiffList; 
+};
+
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svRuleDiff.h b/pgadmin/include/sv/svRuleDiff.h
new file mode 100644
index 0000000..18a85a3
--- /dev/null
+++ b/pgadmin/include/sv/svRuleDiff.h
@@ -0,0 +1,62 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svRuleDiff.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svRuleDiff.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_RULE_DIFF
+#define SV_RULE_DIFF
+
+#include "wx/dynarray.h"
+#include "sv/svDiffObject.h"
+#include "sv/svDiffElement.h"
+
+class pgObject;
+class DiffObject;
+class DiffElement;
+class pgForeignKey;
+class RuleScript;
+
+WX_DEFINE_ARRAY_PTR(RuleElement*, RuleDiffArray); // Diff Elements @ View level
+
+class RuleDiff:public DiffObject
+{
+public:
+	RuleDiff(){}
+	RuleDiff(pgObject * cons):DiffObject(cons){	rulehandle = (pgRule *)cons; }
+	bool GenStructuralDiff(DiffObject * trgPk,ctlTree * src, ctlTree * trg,wxTreeItemId dummyId,RuleScript * fkScr);
+	pgRule *GetRule(){ return rulehandle; }
+	static void DropRuleObject(DiffObject * trgFk, ctlTree* src,ctlTree* trg);
+
+
+private:
+	pgRule *rulehandle;
+	RuleScript *rulescript;
+};
+class RuleScript
+{
+public:
+	RuleScript(){}
+	void GenerateScript();
+	wxString GenerateCreateScript(wxString tableName,wxString schemaName);
+	wxString GenerateAlterScript(wxString &tableName,wxString &schemaName);
+	wxString GenerateDropScript(wxString tableName,wxString schemaName);
+
+	void ApplyScript();
+	void AddDiffElement(RuleElement * de);
+	bool IsPresent(wxString schemaName);
+	DiffElement *GetElement(wxString schemaName);
+
+	int SearchObject(wxString tableName,wxString objName,int metaType,wxString schemaName);
+	RuleDiffArray &GetRuleList(){return ruleDiffList;}
+private:
+	RuleDiffArray ruleDiffList; 
+	
+};
+
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svSchemaDiff.h b/pgadmin/include/sv/svSchemaDiff.h
new file mode 100644
index 0000000..13f5b3a
--- /dev/null
+++ b/pgadmin/include/sv/svSchemaDiff.h
@@ -0,0 +1,91 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svSchemaDiff.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svSchemaDiff.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef SV_SCHEMADIFF
+#define SV_SCHEMADIFF
+
+#include "wx/dynarray.h"
+//#include "sv/svSchemaDiff.h"
+#include "sv/svDiffObject.h"
+#include "sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+
+class DiffObject;
+class pgSchema;
+class ctlTree;
+class pgObject;
+class DiffElement;
+class TableScript;
+class ViewScript;
+class SchemaScript;
+
+
+
+WX_DEFINE_ARRAY_PTR(DiffObject*, SchemaObjArray); // holds objects under schema (currently only tables,views)
+
+
+class SchemaDiff:public DiffObject
+{
+public:
+	SchemaDiff(){}
+	SchemaDiff(pgObject * schema);
+
+	void LoadDiffSystemObjects(wxTreeItemId schemaRoot, ctlTree *);
+	bool GenStructuralDiff(DiffObject * trgSchema,ctlTree * src, ctlTree * trg, wxTreeItemId dummyId,SchemaScript *schScr);
+	void GenStrTableDiff(DiffObject * trgSchema,ctlTree * src, ctlTree * trg, wxTreeItemId dummyId,SchemaScript *schScr);
+	void GenStrViewDiff(DiffObject * trgSchema,ctlTree * src, ctlTree * trg, wxTreeItemId dummyId,SchemaScript *schScr);
+	void ApplyDiff();
+	
+	SchemaObjArray& GetSchemaObjList(){	return objlist;	}
+	pgSchema *GetSchema(){	return schemahandle; }
+	
+	int GetDiffType(){	return meta_type; }
+	void SetDiffType(int type){ meta_type=type;	}
+	
+	DiffObject *FindObj(wxString objname,int meta_type);
+
+	bool IsPresent(wxString,int meta);
+	static void DropSchemaObject(DiffObject * trgSchema, ctlTree* src,ctlTree* trg,SchemaScript *schScr);
+
+private:
+	pgSchema * schemahandle;
+	SchemaObjArray objlist;
+	SchemaScript *schemascript;
+	int meta_type;
+	bool schemaChangesExist;
+};
+
+
+class SchemaScript
+{
+public:
+	SchemaScript(){}
+	void Initialize();
+	void GenerateScript();
+	wxString GenerateCreateScript(wxString schemaName);
+	wxString GenerateAlterScript(wxString schemaName);
+	wxString GenerateDropScript(wxString schemaName);
+	wxString GenerateFkScripts(wxString schemaName);
+
+	void ApplyScript();
+	void AddDiffElement(DiffElement * de);
+	bool IsPresent(wxString schemaName);
+	DiffElement *GetElement(wxString schemaName);
+	TableScript *GetTableScriptHandle(){ return  tableScript; }
+	ViewScript *GetViewScriptHandle(){ return viewScript; }
+private:
+	TableScript *tableScript;
+	ViewScript *viewScript;
+};
+
+
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svTableDiff.h b/pgadmin/include/sv/svTableDiff.h
new file mode 100644
index 0000000..5b2bfe2
--- /dev/null
+++ b/pgadmin/include/sv/svTableDiff.h
@@ -0,0 +1,166 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svTableDiff.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svTableDiff.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_TABLEDIFF
+#define SV_TABLEDIFF
+
+#include "wx/dynarray.h"
+#include "wx/grid.h"
+
+#include "sv/svDiffObject.h"
+#include "sv/svDiffElement.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svFkDiff.h"
+#include "utils/misc.h"
+
+class pgObject;
+class pgTable;
+class DiffObject;
+class DiffElement;
+class ctlTree;
+class IndexDiff;
+class PkDiff;
+class TableScript;
+class PkScript;
+class FkScript;
+class ColumnScript;
+class UniqueScript;
+class IndexScript;
+class DependencyObj;
+class ViewScript;
+
+WX_DEFINE_ARRAY_PTR(TableElement*, SchemaObjTableDiffArray); // Diff Elements under schema level
+WX_DEFINE_ARRAY_PTR(DependencyObj*, DependentObjArray); // Diff Elements under schema level
+
+WX_DEFINE_ARRAY_PTR(DiffObject*, ColumnArray); // holds objects inside a table
+WX_DEFINE_ARRAY_PTR(DiffObject*, UniqueArray); // holds objects inside a Unique
+WX_DEFINE_ARRAY_PTR(DiffObject*, FKeyArray); // holds objects inside a table
+WX_DEFINE_ARRAY_PTR(DiffObject*, IndexArray); // holds objects inside a table
+
+
+WX_DEFINE_ARRAY_INT(int, CreateTableArray); 
+WX_DEFINE_ARRAY_INT(int, DropTableArray); 
+WX_DEFINE_ARRAY_INT(int, AlterTableArray); 
+
+
+class TableDiff:public DiffObject
+{
+public:
+	TableDiff(){}
+	TableDiff(pgObject * table);
+	void LoadDiffSystemObjects(wxTreeItemId tableRoot, ctlTree *);
+
+	bool GenStructuralDiff(DiffObject * trgTable, ctlTree * src, ctlTree * trg, wxTreeItemId dummyId,TableScript * tabScr,ViewScript* viewScr);
+	void GenStrColumnDiff(DiffObject * trgTable, ctlTree * src, ctlTree * trg, wxTreeItemId dummyId,TableScript * tabScr,ViewScript * viewScr);
+	void GenStrIndexDiff(DiffObject * trgTable, ctlTree * src, ctlTree * trg, wxTreeItemId dummyId,TableScript * tabScr);
+	void GenStrFkDiff(DiffObject * trgTable, ctlTree * src, ctlTree * trg, wxTreeItemId dummyId,TableScript * tabScr);
+	void GenStrPkDiff(DiffObject * trgTable, ctlTree * src, ctlTree * trg, wxTreeItemId dummyId,TableScript * tabScr);
+	void GenStrUniqueDiff(DiffObject * trgTable, ctlTree * src, ctlTree * trg, wxTreeItemId dummyId,TableScript * tabScr);
+
+	static void GetDependents(pgObject * obj,DependentObjArray &depList,const wxString &wh);
+	static void FetchDep(pgObject *obj,wxString query,const wxString &clsorder,DependentObjArray &depList);
+	
+	static void BindDropPkDependents(TableScript *tabScr,DependentObjArray &depList,PkElement* pkElem,pgObject * pkObject);
+	static void BindDropUniqueDependents(TableScript *tabScr,DependentObjArray &depList,UniqueElement* uniqueElem,pgObject * uniqueObject);
+	static void BindDropColumnDependents(TableScript *tabScr,ViewScript* viewScr,DependentObjArray &depList,ColumnElement* colElem,pgObject * columnObject);
+
+	void ApplyDiff();
+	
+	bool IsColPresent(wxString objname);
+	bool IsIndexPresent(wxString objname);
+	bool IsFkPresent(wxString objname);
+	bool IsPkPresent(wxString objname);
+
+	ColumnArray& GetColumnObjList(){	return colObjList;	}
+	IndexArray& GetIndexObjList(){	return indObjList;	}
+	FKeyArray& GetFkObjList(){	return fkObjList;	}
+	UniqueArray& GetUniqueObjList(){	return uniqueObjList;	}
+
+	DiffObject *FindColObj(wxString objname);
+	DiffObject *FindFkObj(wxString objname);
+	DiffObject *FindIndexObj(wxString objname);
+	DiffObject *FindUniqueObj(wxString objname);
+	
+	void SetPk(DiffObject *pk){	this->primaryKey=(PkDiff*)pk;}
+	PkDiff *GetPk(){ return this->primaryKey;}
+	pgTable *GetTable(){ return tablehandle; }
+	TableScript *GetTableScript(){return tablescript;}
+	
+
+	static void DropTableObject(DiffObject * trgTable, ctlTree *src,ctlTree *trg,TableScript * tabScr,ViewScript *viewScr);
+	static void DropColumnObject(DiffObject * trgColumn,ctlTree* src,ctlTree* trg,TableScript * tabScr,ViewScript *viewScr);
+	static void DropPkObject(DiffObject * trgPk, ctlTree *src,ctlTree *trg,TableScript * tabScr);
+	static void DropFkObject(DiffObject * trgFk, ctlTree *src,ctlTree *trg,TableScript * tabScr);
+	static void DropUniqueObject(DiffObject * trgUnique, ctlTree *src,ctlTree *trg,TableScript * tabScr);
+	static void DropIndexObject(DiffObject * trgIndex, ctlTree *src,ctlTree *trg,TableScript * tabScr);
+	static wxString RemoveQuotes(wxString str);
+
+
+private:
+	pgTable * tablehandle;
+	PkDiff * primaryKey;
+
+	ColumnArray colObjList;
+	FKeyArray  fkObjList;
+	IndexArray indObjList;
+	UniqueArray uniqueObjList;
+	
+	TableScript *tablescript;
+	bool tableChangesExist;
+};
+
+class TableScript
+{
+public:
+	TableScript(){}
+	void GenerateScript();
+	wxString GenerateCreateScript(wxString schemaName);
+	wxString GenerateAlterScript(wxString schemaName);
+	wxString GenerateDropScript(wxString schemaName);
+
+	void ApplyScript();
+	void Initialize(ViewScript * viewScr);
+	void AddDiffElement(TableElement * de);
+
+	wxString CreateTableScript(wxString tableName,wxString schemaName);
+	wxString AlterTableScript(wxString tableName,wxString schemaName,wxString ObjType);
+	wxString DropTableScript(wxString tableName,wxString schemaName);
+
+	void CreatingIndexes(wxString schemaName,
+							CreateTableArray &createTableIndexes,
+							AlterTableArray  &alterTableIndexes,
+							DropTableArray   &dropTableIndexes);
+
+	wxString GenerateCreateFkScripts(wxString schemaName);
+	wxString GenerateAlterFkScripts(wxString schemaName);
+
+	PkScript* GetPkScript(){return pkScript;}
+	FkScript* GetFkScript(){return fkScript;}
+	IndexScript* GetIndexScript(){return indexScript;}
+	UniqueScript* GetUniqueScript(){return uniqueScript;}
+	ColumnScript* GetColumnScript(){return columnScript;}
+	ViewScript* GetViewScript(){return viewScript;}
+
+	bool ShowDiff(pgObject * selObj, wxGrid * grid,bool sync);
+	bool ProcessDiff(wxString tabName ,wxString schemaName, wxGrid *grid,bool sync);
+	bool IsPresent(wxString schemaName);
+	DiffElement *GetElement(wxString schemaName);
+private:
+	PkScript *pkScript;
+	FkScript *fkScript;
+	IndexScript *indexScript;
+	UniqueScript *uniqueScript;
+	ColumnScript *columnScript;
+	ViewScript *viewScript; // having this handle to resolve dependents
+	SchemaObjTableDiffArray tableDiffList;
+
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svUniqueDiff.h b/pgadmin/include/sv/svUniqueDiff.h
new file mode 100644
index 0000000..150534c
--- /dev/null
+++ b/pgadmin/include/sv/svUniqueDiff.h
@@ -0,0 +1,59 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svUniqueDiff.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svUniqueDiff.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_UNIQUE_DIFF
+#define SV_UNIQUE_DIFF
+
+#include "wx/dynarray.h"
+#include "sv/svDiffObject.h"
+#include "sv/svDiffElement.h"
+#include "sv/svFkDiff.h"
+#include "sv/svTableDiff.h"
+
+class pgObject;
+class DiffObject;
+class DiffElement;
+class pgUnique;
+class UniqueScript;
+
+WX_DEFINE_ARRAY_PTR(UniqueElement*, UniqueDiffArray); // Diff Elements @ constraint level
+
+class UniqueDiff:public DiffObject
+{
+public:
+	UniqueDiff(pgObject * cons):DiffObject(cons){	uchandle = (pgUnique *)cons;	}
+	bool GenStructuralDiff(DiffObject * trgUC,ctlTree * src, ctlTree * trg,wxTreeItemId dummyId,TableScript *tabScr);
+	pgUnique *GetUnique(){ return uchandle; }
+	static void DropUniqueObject(DiffObject * trgUnique,ctlTree* src,ctlTree* trg);
+	wxString RemoveQuotes(wxString str);
+
+
+private:
+	pgUnique *uchandle;
+	UniqueScript *uniquescript;
+};
+class UniqueScript
+{
+public:
+	UniqueScript(){}
+	void GenerateScript();
+	wxString GenerateCreateScript(wxString tableName,wxString schemaName);
+	wxString GenerateAlterScript(wxString tableName,wxString schemaName,FkScript * fkScr,wxString ObjType);
+	wxString GenerateDropScript(wxString tableName,wxString schemaName,FkScript * fkScr);
+
+	void AddDiffElement(UniqueElement * de);
+	int SearchObject(wxString tableName,wxString objName,int metaType,wxString schemaName);
+	UniqueDiffArray &GetUniqueList(){return uniqueDiffList;}
+
+private:
+	UniqueDiffArray uniqueDiffList; 
+};
+#endif
\ No newline at end of file
diff --git a/pgadmin/include/sv/svViewDiff.h b/pgadmin/include/sv/svViewDiff.h
new file mode 100644
index 0000000..edd9946
--- /dev/null
+++ b/pgadmin/include/sv/svViewDiff.h
@@ -0,0 +1,89 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svViewDiff.h 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svViewDiff.h - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SV_VIEWDIFF_H
+#define SV_VIEWDIFF_H
+
+#include "wx/dynarray.h"
+#include "sv/svDiffObject.h"
+
+class pgObject;
+class pgTable;
+class pgView;
+class DiffObject;
+class ViewElement;
+class ctlTree;
+class ViewScript;
+class RuleScript;
+
+
+WX_DEFINE_ARRAY_PTR(DiffObject*, ViewColumnArray); // holds objects inside a view
+WX_DEFINE_ARRAY_PTR(DiffObject*, ViewRuleArray); // holds objects inside a view
+WX_DEFINE_ARRAY_PTR(ViewElement*, ViewObjDiffArray); // holds objects inside a view
+
+class ViewDiff:public DiffObject
+{
+public:
+	ViewDiff(){}
+	ViewDiff(pgObject * view);
+
+	ViewDiff *FindObj();
+	pgView *GetView(){return viewhandle;}
+
+	void LoadDiffSystemObjects(wxTreeItemId viewRoot, ctlTree *);
+	bool GenStructuralDiff(DiffObject * trgView,ctlTree * src, ctlTree * trg,wxTreeItemId dummyId,ViewScript * viewScr);
+	void GenStrColumnDiff(DiffObject * trgTable, ctlTree * src, ctlTree * trg, wxTreeItemId dummyId,ViewScript * viewScr);
+	void GenStrRuleDiff(DiffObject * trgTable, ctlTree * src, ctlTree * trg, wxTreeItemId dummyId,ViewScript * viewScr);
+	void ApplyDiff();
+	
+	static void DropViewObject(DiffObject * trgV,ctlTree * src,ctlTree* trg,ViewScript * viewScr);
+	static void DropColumnObject(DiffObject * trgV,ctlTree * src, ctlTree * trg,ViewScript * viewScr);
+	static void DropRuleObject(DiffObject * trgV,ctlTree * src, ctlTree * trg,ViewScript * viewScr);
+	
+	bool IsColPresent(wxString objname);
+	bool IsRulePresent(wxString objname);
+
+	DiffObject *FindColObj(wxString objname);
+	DiffObject *FindRuleObj(wxString objname);
+	
+	ViewColumnArray& GetColumnObjList(){	return colObjList;	}
+	ViewRuleArray& GetRuleObjList(){	return ruleObjList;	}
+	
+
+private:
+	pgView * viewhandle;
+	ViewColumnArray colObjList;
+	ViewRuleArray ruleObjList;
+
+	ViewScript *viewScript;
+	bool viewChangesExist;
+	
+};
+
+class ViewScript
+{
+public:
+	ViewScript(){}
+	void Initialize();
+	void GenerateScript();
+	wxString GenerateCreateScript(wxString schemaName);
+	wxString GenerateDropScript(wxString schemaName);
+	void AddDiffElement(ViewElement * de);
+
+	int SearchObject(wxString viewName,int metaType,wxString schemaName);
+	RuleScript *GetRuleScriptHandle(){return ruleScript;}
+	ViewObjDiffArray &GetViewList(){return viewDiffList;}
+private:
+	ViewObjDiffArray viewDiffList;
+	RuleScript *ruleScript;
+};
+
+#endif
\ No newline at end of file
diff --git a/pgadmin/schema/pgColumn.cpp b/pgadmin/schema/pgColumn.cpp
index 88516c5..d843ff8 100644
--- a/pgadmin/schema/pgColumn.cpp
+++ b/pgadmin/schema/pgColumn.cpp
@@ -337,7 +337,19 @@ wxString pgColumn::GetDefinition()
     return sql;
 }
 
-
+void pgColumn::SetPK()
+{
+	wxStringTokenizer indkey(pkCols);
+    while (indkey.HasMoreTokens())
+    {
+        wxString str=indkey.GetNextToken();
+        if (StrToLong(str) == GetColNumber())
+        {
+            isPK = true;
+            break;
+        }
+    }
+}
 void pgColumn::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
 {
     if (!expandedKids)
diff --git a/pgadmin/schema/pgForeignKey.cpp b/pgadmin/schema/pgForeignKey.cpp
index 8898806..17e59f8 100644
--- a/pgadmin/schema/pgForeignKey.cpp
+++ b/pgadmin/schema/pgForeignKey.cpp
@@ -162,6 +162,40 @@ wxString pgForeignKey::GetFullName()
     return GetName() + wxT(" -> ") + GetReferences();
 }
 
+void pgForeignKey::ReadFkColumnInfo() 
+{
+	// making this code publically accessible to set fkcolumns and reference column for a key
+	wxStringTokenizer c1l(GetConkey(), wxT(","));
+    wxStringTokenizer c2l(GetConfkey(), wxT(","));
+    wxString c1, c2;
+
+    while (c1l.HasMoreTokens())
+    {
+        c1=c1l.GetNextToken();
+        c2=c2l.GetNextToken();
+        pgSet *set=ExecuteSet(
+            wxT("SELECT a1.attname as conattname, a2.attname as confattname\n")
+            wxT("  FROM pg_attribute a1, pg_attribute a2\n")
+            wxT(" WHERE a1.attrelid=") + GetTableOidStr() + wxT(" AND a1.attnum=") + c1 + wxT("\n")
+            wxT("   AND a2.attrelid=") + GetRelTableOidStr() + wxT(" AND a2.attnum=") + c2);
+        if (set)
+        {
+            if (!fkColumns.IsNull())
+            {
+                fkColumns += wxT(", ");
+                refColumns += wxT(", ");
+                quotedFkColumns += wxT(", ");
+                quotedRefColumns += wxT(", ");
+            }
+            fkColumns += set->GetVal(0);
+            refColumns += set->GetVal(1);
+            quotedFkColumns += qtIdent(set->GetVal(0));
+            quotedRefColumns += qtIdent(set->GetVal(1));
+            delete set;
+        }
+    }
+}
+
 void pgForeignKey::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
 {
     if (!expandedKids)
diff --git a/pgadmin/schema/pgIndex.cpp b/pgadmin/schema/pgIndex.cpp
index 9ef3b96..9569c88 100644
--- a/pgadmin/schema/pgIndex.cpp
+++ b/pgadmin/schema/pgIndex.cpp
@@ -164,8 +164,6 @@ wxString pgIndexBase::GetSql(ctlTree *browser)
     return sql;
 }
 
-
-
 void pgIndexBase::ReadColumnDetails()
 {
     if (!expandedKids)
@@ -451,7 +449,10 @@ pgIndex::pgIndex(pgTable *newTable, const wxString& newName)
 : pgIndexBase(newTable, indexFactory, newName)
 {
 }
-
+void pgIndex::ReadIndexColumnInfo()
+{
+	this->ReadColumnDetails();
+}
 
 pgObject *pgIndexBaseFactory::CreateObjects(pgCollection *coll, ctlTree *browser, const wxString &restriction)
 {
diff --git a/pgadmin/schema/pgIndexConstraint.cpp b/pgadmin/schema/pgIndexConstraint.cpp
index d377a5f..e151f92 100644
--- a/pgadmin/schema/pgIndexConstraint.cpp
+++ b/pgadmin/schema/pgIndexConstraint.cpp
@@ -141,7 +141,10 @@ wxString pgIndexConstraint::GetCreate()
     return sql;
 };
 
-
+void pgIndexConstraint::ReadColumnInfo()
+{
+	this->ReadColumnDetails();
+}
 wxString pgIndexConstraint::GetSql(ctlTree *browser)
 {
     if (sql.IsNull())
@@ -226,6 +229,15 @@ pgObject *pgExclude::Refresh(ctlTree *browser, const wxTreeItemId item)
     return index;
 }
 
+void pgUnique::ReadUniqueColumnInfo()
+{
+	ReadColumnInfo();  // accessing pgIndexBase "ReadColumnDetails()" through pgIndexConstraint function
+}
+void pgPrimaryKey::ReadPkColumnInfo()
+{
+	ReadColumnInfo(); // accessing pgIndexBase "ReadColumnDetails()" through pgIndexConstraint function
+}
+
 pgObject *pgPrimaryKeyFactory::CreateObjects(pgCollection *collection, ctlTree *browser, const wxString &where)
 {
     return pgIndexBaseFactory::CreateObjects(collection, browser, wxT("   AND contype='p'\n") + where);
diff --git a/pgadmin/schema/pgObject.cpp b/pgadmin/schema/pgObject.cpp
index 314a2e8..096b487 100644
--- a/pgadmin/schema/pgObject.cpp
+++ b/pgadmin/schema/pgObject.cpp
@@ -905,6 +905,14 @@ wxTreeItemId pgObject::AppendBrowserItem(ctlTree *browser, pgObject *object)
 }
 
 
+bool pgObject::GetExpandedStatus()
+{
+	return expandedKids;
+}
+void pgObject::SetExpandedStatus()
+{
+	expandedKids = true;
+}
 wxString pgObject::GetCommentSql()
 {
     wxString cmt;
diff --git a/pgadmin/sv/dlgAuthServer.cpp b/pgadmin/sv/dlgAuthServer.cpp
new file mode 100644
index 0000000..f0a1466
--- /dev/null
+++ b/pgadmin/sv/dlgAuthServer.cpp
@@ -0,0 +1,353 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: dlgAuthServer.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dlgAuthServer.cpp - User authentication dialog for sync viewer
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+#include "frm/frmMain.h"
+#include "schema/pgServer.h"
+#include "schema/pgDatabase.h"
+#include "sv/dlgAuthServer.h"
+#include "sv/dlgDbDiff.h"
+
+//#include "dlg/dlgSelectDatabase.h"
+
+
+BEGIN_EVENT_TABLE(dlgAuthServer, wxDialog)
+    EVT_BUTTON(XRCID("ID_SELECT"),dlgAuthServer::onOK )
+	EVT_BUTTON(XRCID("ID_CANCEL"),dlgAuthServer::onCancel )
+	EVT_TREE_ITEM_ACTIVATED(XRCID("ID_TREECTRL_SRC"), dlgAuthServer::OnSelActivatedSrc)
+	EVT_TREE_ITEM_ACTIVATED(XRCID("ID_TREECTRL_TRG"), dlgAuthServer::OnSelActivatedTrg)
+	//EVT_TREE_SEL_CHANGED(XRCID("ID_TREECTRL_SRC"),dlgAuthServer::OnTreeSelChanged)
+	EVT_TREE_SEL_CHANGED(XRCID("ID_TREECTRL_SRC"),dlgAuthServer::OnSrcGetSelection)
+	EVT_TREE_SEL_CHANGED(XRCID("ID_TREECTRL_TRG"),dlgAuthServer::OnTrgGetSelection)
+
+	EVT_CLOSE(dlgAuthServer::DialogClose)
+END_EVENT_TABLE()
+
+dlgAuthServer::dlgAuthServer(wxWindow *form)
+{
+	this->LoadResource(form, wxT("dlgAuthServers")); // pgDialog would handle dialog loading for you
+	dlgParent = (frmMain *)form;
+	dbDiff = NULL;
+	sourcedb=NULL;
+	targetdb=NULL;
+	srcDbSel=false;
+	trgDbSel=false;
+}
+
+dlgAuthServer::~dlgAuthServer()
+{
+	// unlinking the common objects btw the two trees
+	wxTreeItemId root,groupitem,serveritem;
+	wxCookieType groupcookie,serveritemcookie;
+	root = treectrltrg->GetRootItem();
+	
+	groupitem = treectrltrg->GetFirstChild(root,groupcookie);
+	while(groupitem)
+	{
+		serveritem = treectrltrg->GetFirstChild(groupitem,serveritemcookie);
+		while(serveritem)
+		{
+			pgServer * pgS = (pgServer *)treectrltrg->GetObject(serveritem);
+			if(pgS->GetConnected())
+			{
+				treectrltrg->SetItemData(serveritem,NULL); // unlink objects
+			}
+			serveritem = treectrltrg->GetNextChild(groupitem,serveritemcookie);
+		}
+		groupitem = treectrltrg->GetNextChild(root,groupcookie);
+	}
+}
+
+void dlgAuthServer::DialogClose(wxCloseEvent &event)
+{
+	Destroy();
+
+}
+void dlgAuthServer::onOK(wxCommandEvent& event)
+{
+
+	// must check here that both db are selected(using a double click - for now) 
+	if(!dbDiff)
+	{
+		// if source and target is same
+		if(this->sourcedb && this->targetdb)
+		{
+			dbDiff = new dlgDbDiff(this,this->SourceServer,this->TargetServer,this->sourcedb,this->targetdb);
+			this->Show(false);
+		}
+	}
+	
+}
+void dlgAuthServer::onCancel(wxCommandEvent& event){
+	Close(true);
+}
+void dlgAuthServer::CreateTree(wxWindow *p)
+{
+
+	treectrlsrc = XRCCTRL(*p, "ID_TREECTRL_SRC", ctlTree);
+	treectrlsrc->SetImageList(imageList);
+	
+	treectrltrg = XRCCTRL(*p, "ID_TREECTRL_TRG", ctlTree);
+	treectrltrg->SetImageList(imageList);
+	
+	serversObjSrc = new pgServerCollection(serverFactory.GetCollectionFactory());
+	serversObjTrg = new pgServerCollection(serverFactory.GetCollectionFactory());
+	
+	rootsrc = treectrlsrc->AddRoot(_("Source Servers "), serversObjSrc->GetIconId(), -1, serversObjSrc);
+	roottrg = treectrltrg->AddRoot(_("Target Servers "), serversObjTrg->GetIconId(), -1, serversObjTrg);
+	
+	this->RetrieveServers(treectrlsrc,serversObjSrc);
+	this->RetrieveServers(treectrltrg,serversObjTrg);
+	
+	compareDiffBtn = XRCCTRL(*p, "ID_SELECT", wxButton);
+	compareDiffBtn->Disable();
+	this->Show();
+}
+void dlgAuthServer::RetrieveServers(ctlTree * tree, pgServerCollection * serversObj)
+{
+    wxString label;
+    int total = 0;
+    wxTreeItemIdValue groupcookie;
+    wxTreeItemId groupitem;
+
+	// Create all servers' nodes
+    serverFactory.CreateObjects(serversObj, tree);
+    
+    // Count number of servers and groups
+    groupitem = tree->GetFirstChild(tree->GetRootItem(), groupcookie);
+    while (groupitem)
+    {
+        total = tree->GetChildrenCount(groupitem, false);
+        label = tree->GetItemText(groupitem) + wxT(" (") + NumToStr((long)total) + wxT(")");
+        tree->SetItemText(groupitem, label);
+        tree->SortChildren(groupitem);
+        tree->Expand(groupitem);
+        groupitem = tree->GetNextChild(tree->GetRootItem(), groupcookie);
+    }
+}
+void dlgAuthServer::OnSelActivatedSrc(wxTreeEvent &event)
+{
+	wxTreeItemId item = event.GetItem();
+    pgObject *data = treectrlsrc->GetObject(item);
+    if (!data)
+        return;
+    pgServer *server;
+    wxCommandEvent nullEvent;
+
+    if (data->IsCreatedBy(serverFactory))
+    {
+        server = (pgServer *)data;
+        if (!server->GetConnected())
+        {
+            if (ReconnectServer(server) == PGCONN_OK)
+            {
+				SourceServer = server;
+				int iport;
+				wxString port;
+				iport = SourceServer->GetPort();
+				
+				wxString desc= SourceServer->GetDescription();
+				wxString name = SourceServer->GetName();
+				wxTreeItemId item = FindServer(treectrltrg,desc,name,iport);
+
+				// making the target looks connected
+				if(item)
+				{
+					wxTreeItemId parent;
+					parent = treectrltrg->GetItemParent(item);
+					
+					treectrltrg->AppendItem(parent,SourceServer->GetFullName(),-1,SourceServer->GetIconId(),SourceServer);
+					treectrltrg->Delete(item);
+					treectrltrg->AppendCollection(SourceServer,databaseFactory);
+					treectrltrg->SortChildren(parent);
+					SourceServer->UpdateIcon(treectrltrg);
+				}
+            }
+        }
+    }
+	else if(data->IsCreatedBy(databaseFactory))
+	{
+		pgObject * data = treectrlsrc->GetObject(item);
+		sourcedb = data; // saving the sourcedb
+		SourceServer = data->GetServer();
+	}
+	event.Skip();
+}
+
+void dlgAuthServer::OnSelActivatedTrg(wxTreeEvent &event)
+{
+	wxTreeItemId item = event.GetItem();
+    pgObject *data = treectrltrg->GetObject(item);
+    if (!data)
+        return;
+    pgServer *server;
+    wxCommandEvent nullEvent;
+
+    if (data->IsCreatedBy(serverFactory))
+    {
+        server = (pgServer *)data;
+        if (!server->GetConnected())
+        {
+            if (ReconnectServer(server) == PGCONN_OK)
+            {
+				TargetServer =server;
+				int iport;
+				wxString port;
+				iport = TargetServer->GetPort();
+				
+				wxString desc= TargetServer->GetDescription();
+				wxString name = TargetServer->GetName();
+				wxTreeItemId item = FindServer(treectrlsrc,desc,name,iport);
+
+				// making the target looks connected 
+				if(item)
+				{
+					wxTreeItemId parent;
+					parent = treectrlsrc->GetItemParent(item);
+					
+					treectrlsrc->AppendItem(parent,TargetServer->GetFullName(),-1,TargetServer->GetIconId(),TargetServer);
+					treectrlsrc->Delete(item);
+					treectrlsrc->AppendCollection(TargetServer,databaseFactory);
+					treectrlsrc->SortChildren(parent);
+					TargetServer->UpdateIcon(treectrlsrc);
+				}
+            }
+        }
+    }
+	else if(data->IsCreatedBy(databaseFactory)){
+		pgObject * data = treectrltrg->GetObject(item);
+		targetdb = data; 
+
+		TargetServer = data->GetServer(); // thats it	
+	}
+	
+	event.Skip();
+}
+void dlgAuthServer::OnSrcGetSelection(wxTreeEvent &event)
+{
+	wxTreeItemId item = event.GetItem();
+    pgObject *data = treectrlsrc->GetObject(item);
+	if (!data)
+        return;
+	if(data->IsCreatedBy(databaseFactory))
+	{
+		srcDbSel=true;
+		sourcedb = data; // saving the sourcedb
+		SourceServer = data->GetServer();
+		
+		if(srcDbSel&&trgDbSel)
+			compareDiffBtn->Enable();
+	}
+	else
+	{
+		srcDbSel=false;
+		compareDiffBtn->Disable();
+	}
+}
+void dlgAuthServer::OnTrgGetSelection(wxTreeEvent &event)
+{
+	wxTreeItemId item = event.GetItem();
+    pgObject *data = treectrlsrc->GetObject(item);
+	if (!data)
+        return;
+	if(data->IsCreatedBy(databaseFactory))
+	{
+		trgDbSel=true;
+		targetdb = data; // saving the sourcedb
+		TargetServer = data->GetServer();
+
+		if(srcDbSel&&trgDbSel)
+			compareDiffBtn->Enable();
+	}
+	else
+	{
+		trgDbSel=false;
+		compareDiffBtn->Disable();
+	}
+}
+void dlgAuthServer::OnTreeSelChanged(wxTreeEvent &event)
+{
+}
+int dlgAuthServer::ReconnectServer(pgServer *server, bool restore)
+{
+    int res = server->Connect(dlgParent, true);
+    wxTreeItemId item;
+    switch (res)
+    {
+        case PGCONN_OK:
+        {
+			treectrlsrc->AppendCollection(server, databaseFactory);
+            return res;
+        }
+        case PGCONN_DNSERR:
+        case PGCONN_BAD:
+			dlgParent->ReportConnError(server);
+        default:
+            wxLogInfo(wxT("pgServer object didn't initialise because the user aborted."));
+            break;
+    }
+
+    server->Disconnect(dlgParent);
+    return res;
+}
+wxTreeItemId dlgAuthServer::FindServer(ctlTree *tree, wxString serverName, wxString name, int serverPort)
+{
+	wxTreeItemIdValue foldercookie, servercookie;
+    wxTreeItemId folderitem, serveritem;
+    pgObject *object;
+    pgServer *server;
+
+	//ctlTree * browser = tree->GetBrowser();
+    folderitem = tree->GetFirstChild(tree->GetRootItem(), foldercookie);
+    while (folderitem)
+    {
+        if (tree->ItemHasChildren(folderitem))
+        {
+            serveritem = tree->GetFirstChild(folderitem, servercookie);
+            while (serveritem)
+            {
+                object = tree->GetObject(serveritem);
+                if (object->IsCreatedBy(serverFactory))
+                {
+                    server = (pgServer *)object;
+                    if (server->GetDescription() == serverName && 
+						server->GetName() == name && 
+						server->GetPort()== serverPort )
+                    {
+						//server->getid
+                        return serveritem;
+                    }
+                }
+                serveritem = tree->GetNextChild(folderitem, servercookie);
+            }
+        }
+        folderitem = tree->GetNextChild(tree->GetRootItem(), foldercookie);
+    }
+	return 0;
+}
+
+
+#include "images/syncvisualizer.xpm"
+SyncVisualizerFactory::SyncVisualizerFactory(menuFactoryList * list,wxMenu *mnu,ctlMenuToolbar *toolbar):actionFactory(list)
+{
+	mnu->Append(id, _("&Difference Visualizer..."), _("Sync/Visualize Difference."));
+	toolbar->AddTool(id, _("Difference Visualizer"), wxBitmap(sync_visual_xpm), _("Difference Visualizer."), wxITEM_NORMAL);
+}
+wxWindow *SyncVisualizerFactory::StartDialog(frmMain *form, pgObject *obj)
+{
+	dlgAuthServer * server=NULL;
+	if(server==NULL)
+	{
+		server = new dlgAuthServer(form);
+		server->CreateTree(server);
+	}
+	return 0;
+}
diff --git a/pgadmin/sv/dlgDbDiff.cpp b/pgadmin/sv/dlgDbDiff.cpp
new file mode 100644
index 0000000..e0f22db
--- /dev/null
+++ b/pgadmin/sv/dlgDbDiff.cpp
@@ -0,0 +1,639 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: dlgDbDiff.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dlgDbDiff.cpp -  dialog for sync viewer difference tree
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "wx/image.h"
+
+#include "sv/dlgDbDiff.h"
+#include "sv/svDiffSystem.h"
+#include "sv/dlgDiffObjectViewer.h"
+#include "schema/pgColumn.h"
+#include "schema/pgConstraints.h"
+#include "schema/pgIndex.h"
+#include "schema/pgSchema.h"
+#include "schema/pgServer.h"
+#include "schema/pgDatabase.h"
+#include "schema/pgTable.h"
+#include "schema/pgView.h"
+
+////////////////////////////////////////
+// images headers
+////////////////////////////////////////
+// schema
+#include "images/sv/schema_present_sm.xpm"
+#include "images/sv/schema_missing_sm.xpm"
+#include "images/sv/schema_changed_sm.xpm"
+
+
+// tables
+#include "images/sv/table_present_sm.xpm"
+#include "images/sv/table_missing_sm.xpm"
+#include "images/sv/table_changed_sm.xpm"
+
+// views
+#include "images/sv/view_present_sm.xpm"
+#include "images/sv/view_missing_sm.xpm"
+#include "images/sv/view_changed_sm.xpm"
+
+// columns
+#include "images/sv/column_present_sm.xpm"
+#include "images/sv/column_missing_sm.xpm"
+#include "images/sv/column_changed_sm.xpm"
+
+#include "images/sv/rule_present_sm.xpm"
+#include "images/sv/rule_missing_sm.xpm"
+#include "images/sv/rule_changed_sm.xpm"
+
+// constraints - pk
+#include "images/sv/pk_present_sm.xpm"
+#include "images/sv/pk_missing_sm.xpm"
+#include "images/sv/pk_changed_sm.xpm"
+
+// constraints - fk
+#include "images/sv/fk_present_sm.xpm"
+#include "images/sv/fk_missing_sm.xpm"
+#include "images/sv/fk_changed_sm.xpm"
+
+// constraints - index
+#include "images/sv/index_present_sm.xpm"
+#include "images/sv/index_missing_sm.xpm"
+#include "images/sv/index_changed_sm.xpm"
+// constraints - unique
+#include "images/sv/unique_present_sm.xpm"
+#include "images/sv/unique_missing_sm.xpm"
+#include "images/sv/unique_changed_sm.xpm"
+
+// roots
+//#include "images/chgdatabases-sm.xpm"
+#include "images/sv/schemas_changed_sm.xpm"
+#include "images/sv/tables_changed_sm.xpm"
+#include "images/sv/views_changed_sm.xpm"
+#include "images/sv/columns_changed_sm.xpm"
+#include "images/sv/indexes_changed_sm.xpm"
+#include "images/sv/constraints_changed_sm.xpm"
+#include "images/sv/rules_changed_sm.xpm"
+/////////////////////////////////////////
+
+BEGIN_EVENT_TABLE(dlgDbDiff, wxDialog)
+    EVT_BUTTON(XRCID("ID_BTN_SYNC_STD"),dlgDbDiff::onSync )
+	EVT_BUTTON(XRCID("ID_BTN_VIEW_DIFF"),dlgDbDiff::onDiffViewer )
+	EVT_BUTTON(XRCID("ID_CANCEL"),dlgDbDiff::onCancel )
+	EVT_TREE_ITEM_ACTIVATED(XRCID("ID_TREECTRL_DIFF_SRC"), dlgDbDiff::OnSelActivatedSrcDb)
+	EVT_TREE_ITEM_ACTIVATED(XRCID("ID_TREECTRL_DIFF_TRG"), dlgDbDiff::OnSelActivatedTrgDb)
+	EVT_TREE_ITEM_EXPANDING(XRCID("ID_TREECTRL_DIFF_SRC"),dlgDbDiff::OnExpand)
+	EVT_TREE_SEL_CHANGED(XRCID("ID_TREECTRL_DIFF_TRG"),dlgDbDiff::OnSrcGetSelection)
+END_EVENT_TABLE()
+
+dlgDbDiff::dlgDbDiff()
+{
+}
+dlgDbDiff::dlgDbDiff(dlgAuthServer *parentDialog,pgServer *src, pgServer *trg,pgObject *srcdb,pgObject *trgdb)
+{
+
+	// setting configuration
+	this->connectedSrcServer=src;
+	this->connectedTrgServer=trg;
+	this->sourceDb=srcdb;
+	this->targetDb=trgdb;
+	this->diffSys= new DiffSystem();
+
+	this->LoadResource((wxWindow*)parentDialog,wxT("dlgDbDiff")); // pgDialog would handle dialog loading for you
+	this->dlgParent = (wxWindow*)parentDialog;
+	this->CreateTree();
+	this->CreateNoteBookTabs();
+	dViewer=0;
+}
+dlgDbDiff::~dlgDbDiff()
+{
+	dlgParent=NULL;
+	sourceDb=NULL; 
+	targetDb=NULL;
+
+	// removing the db item reference from the tree by reseting the treeitem to null;
+	treectrlsrcdb->SetItemData(srcdb,NULL);
+	treectrltrgdb->SetItemData(trgdb,NULL);
+	
+}
+void dlgDbDiff::onSync(wxCommandEvent& event)
+{
+	if(diffSys->ApplyDiff() == true)
+	{
+		this->RefreshTargetTree(trgdb); // refreshing the entire target tree structure
+		syncBtn->Disable(); 
+	}
+}
+void dlgDbDiff::onDiffViewer(wxCommandEvent& event)
+{
+	// instantiating diff viewer
+	//if(!dViewer)
+	//	this->dViewer = new dlgDiffObjectViewer(this);
+	//this->dViewer->Show();
+	diffViewerBtn->Disable();
+	this->dViewer->RenderBeforeDifference();
+	
+}
+void dlgDbDiff::onCancel(wxCommandEvent& event)
+{
+	Close(true);
+}
+void dlgDbDiff::CreateTree()
+{
+
+	treectrlsrcdb = XRCCTRL(*(this), "ID_TREECTRL_DIFF_SRC", ctlTree);
+	treectrlsrcdb->SetImageList(imageList);
+	
+	treectrltrgdb = XRCCTRL(*(this), "ID_TREECTRL_DIFF_TRG", ctlTree);
+	treectrltrgdb->SetImageList(imageList);
+
+	syncBtn = XRCCTRL(*(this), "ID_BTN_SYNC_STD", wxButton);
+	diffViewerBtn = XRCCTRL(*(this), "ID_BTN_VIEW_DIFF", wxButton);
+	diffViewerBtn->Disable();
+
+	// assuming that the servers referred are already connected
+	wxTreeItemId serverSrcId = treectrlsrcdb->AddRoot(this->connectedSrcServer->GetFullName(), this->connectedSrcServer->GetIconId(), -1, NULL);
+	wxTreeItemId serverTrgId = treectrltrgdb->AddRoot(this->connectedTrgServer->GetFullName(), this->connectedTrgServer->GetIconId(), -1, NULL);
+	
+	// sourceDb is accessed from parent have to see how it respond if tree is destroyed
+	// assuming here that the data base handles are there
+	pgDatabase *tmpSource =((pgDatabase*)sourceDb)->GetDatabase();
+	pgDatabase *tmpTarget =((pgDatabase*)targetDb)->GetDatabase();
+	
+	if (tmpSource->Connect() == PGCONN_OK && 
+		tmpTarget->Connect() == PGCONN_OK)
+    {
+        
+        sourceDb->UpdateIcon(treectrlsrcdb);
+		targetDb->UpdateIcon(treectrltrgdb);
+
+		srcdb = treectrlsrcdb->AppendItem(treectrlsrcdb->GetRootItem(),
+														sourceDb->GetDisplayName(), 
+														((pgDatabase*)sourceDb)->GetIconId(), 
+														-1, 
+														sourceDb);
+		trgdb = treectrltrgdb->AppendItem(treectrltrgdb->GetRootItem(),
+														targetDb->GetDisplayName(), 
+														((pgDatabase*)targetDb)->GetIconId(), 
+														-1, 
+														targetDb);
+    
+		treectrltrgdb->AppendCollection((pgDatabase*)targetDb,schemaFactory);
+		treectrlsrcdb->AppendCollection((pgDatabase*)sourceDb,schemaFactory);
+		
+		// creating objects for db
+		Load(srcdb,treectrlsrcdb,true);
+		Load(trgdb,treectrltrgdb,true);
+
+		// expanding the tree upto schema level
+		treectrlsrcdb->Expand(serverSrcId);
+		treectrltrgdb->Expand(serverTrgId);
+		treectrlsrcdb->Expand(srcdb);
+		treectrltrgdb->Expand(trgdb);
+
+		// starting/initializing the diff system
+		diffSys->SetDatabase((pgDatabase*)sourceDb,(pgDatabase*)targetDb);
+		diffSys->Initialize(treectrlsrcdb,treectrltrgdb);
+	
+		this->Show(true);
+	}
+	else
+		Close(true); 
+}
+void dlgDbDiff::OnSelActivatedSrcDb(wxTreeEvent &event)
+{
+	wxTreeItemId item = event.GetItem();
+    pgObject *data = treectrlsrcdb->GetObject(item);
+
+	if(!data)
+		event.Skip();
+	else
+	{
+		if(!diffSys->IsDiffTaken())
+			diffSys->GenSrcDiff(item); 
+	}
+	event.Skip();
+}
+void dlgDbDiff::OnSelActivatedTrgDb(wxTreeEvent &event)
+{
+	wxTreeItemId item = event.GetItem();
+    pgObject *data = treectrltrgdb->GetObject(item);
+
+	if(!data)
+	{
+		event.Skip();
+	}
+	event.Skip();
+}
+
+void dlgDbDiff::OnExpand(wxTreeEvent &event)
+{
+}
+void dlgDbDiff::CreateNoteBookTabs()
+{
+	notebook = XRCCTRL(*(this), "ID_NTB", wxNotebook);
+	CreateSchemaTab(notebook);
+	wxPanel * legendpanel = CreateLegendTab(notebook);;
+	
+	// for now just making schema tab
+	notebook->AddPage( legendpanel,wxT("Legend") , false, -1 );
+	notebook->AddPage( this->grid,wxT("Schema Difference") , false, -1 );
+	
+}
+wxPanel *dlgDbDiff::CreateLegendTab(wxNotebook *parent)
+{
+	wxPanel *panel = new wxPanel(parent);
+	
+	// showing schema
+	wxBitmap *schemas_changed = new wxBitmap(schemas_changed_sm_xpm);
+	wxBitmap *schema_missing = new wxBitmap(schema_missing_sm_xpm);
+	wxBitmap *schema_present = new wxBitmap(schema_present_sm_xpm);
+	
+	wxStaticBitmap *bmpSchemasChanged = new wxStaticBitmap(panel, wxID_ANY, *schemas_changed, wxPoint(10,5));
+	wxStaticText *textSchemasChanged = new wxStaticText(panel, wxID_ANY, wxT("Schemas change exist"), wxPoint(30,5));
+
+	wxStaticBitmap *bmpSchemaMissing = new wxStaticBitmap(panel, wxID_ANY, *schema_missing, wxPoint(280,5));
+	wxStaticText *textSchemaMissing = new wxStaticText(panel, wxID_ANY, wxT("Drop Schema"), wxPoint(300,5));
+
+	wxStaticBitmap *bmpSchemaPresent = new wxStaticBitmap(panel, wxID_ANY, *schema_present, wxPoint(160,5));
+	wxStaticText *textSchemaPresent = new wxStaticText(panel, wxID_ANY, wxT("Add Schema"), wxPoint(180,5));
+
+	
+	// showing table
+	wxBitmap *tables_changed = new wxBitmap(tables_changed_sm_xpm);
+	wxBitmap *table_missing = new wxBitmap(table_missing_sm_xpm);
+	wxBitmap *table_present = new wxBitmap(table_present_sm_xpm);
+	
+	wxStaticBitmap *bmpTablesChanged = new wxStaticBitmap(panel, wxID_ANY, *tables_changed, wxPoint(10,25));
+	wxStaticText *textTablesChanged = new wxStaticText(panel, wxID_ANY, wxT("Tables change exist"), wxPoint(30,25));
+
+	wxStaticBitmap *bmpTableMissing = new wxStaticBitmap(panel, wxID_ANY, *table_missing, wxPoint(280,25));
+	wxStaticText *textTableMissing = new wxStaticText(panel, wxID_ANY, wxT("Drop Table"), wxPoint(300,25));
+
+	wxStaticBitmap *bmpTablePresent = new wxStaticBitmap(panel, wxID_ANY, *table_present, wxPoint(160,25));
+	wxStaticText *textTablePresent = new wxStaticText(panel, wxID_ANY, wxT("Add Table"), wxPoint(180,25));
+
+	
+	// showing view
+	wxBitmap *views_changed = new wxBitmap(views_changed_sm_xpm);
+	wxBitmap *view_missing = new wxBitmap(view_missing_sm_xpm);
+	wxBitmap *view_present = new wxBitmap(view_present_sm_xpm);
+	
+	wxStaticBitmap *bmpViewsChanged = new wxStaticBitmap(panel, wxID_ANY, *views_changed, wxPoint(10,45));
+	wxStaticText *textViewsChanged = new wxStaticText(panel, wxID_ANY, wxT("Views change exist"), wxPoint(30,45));
+
+	wxStaticBitmap *bmpViewMissing = new wxStaticBitmap(panel, wxID_ANY, *view_missing, wxPoint(280,45));
+	wxStaticText *textViewMissing = new wxStaticText(panel, wxID_ANY, wxT("Drop View"), wxPoint(300,45));
+
+	wxStaticBitmap *bmpViewPresent = new wxStaticBitmap(panel, wxID_ANY, *view_present, wxPoint(160,45));
+	wxStaticText *textViewPresent = new wxStaticText(panel, wxID_ANY, wxT("Add View"), wxPoint(180,45));
+
+	
+	// showing column
+	wxBitmap *columns_changed = new wxBitmap(columns_changed_sm_xpm);
+	wxBitmap *column_missing = new wxBitmap(column_missing_sm_xpm);
+	wxBitmap *column_present = new wxBitmap(column_present_sm_xpm);
+	
+	wxStaticBitmap *bmpColumnChanged = new wxStaticBitmap(panel, wxID_ANY, *columns_changed, wxPoint(10,65));
+	wxStaticText *textColumnsChanged = new wxStaticText(panel, wxID_ANY, wxT("Columns change exist"), wxPoint(30,65));
+
+	wxStaticBitmap *bmpColumnMissing = new wxStaticBitmap(panel, wxID_ANY, *column_missing, wxPoint(280,65));
+	wxStaticText *textColumnMissing = new wxStaticText(panel, wxID_ANY, wxT("Drop Column"), wxPoint(300,65));
+
+	wxStaticBitmap *bmpColumnPresent = new wxStaticBitmap(panel, wxID_ANY, *column_present, wxPoint(160,65));
+	wxStaticText *textColumnPresent = new wxStaticText(panel, wxID_ANY, wxT("Add Column"), wxPoint(180,65));
+
+
+	// showing indexes
+	wxBitmap *indexes_changed = new wxBitmap(indexes_changed_sm_xpm);
+	wxBitmap *index_missing = new wxBitmap(index_missing_sm_xpm);
+	wxBitmap *index_present = new wxBitmap(index_present_sm_xpm);
+	
+	wxStaticBitmap *bmpIndexChanged = new wxStaticBitmap(panel, wxID_ANY, *indexes_changed, wxPoint(10,85));
+	wxStaticText *textIndexChanged = new wxStaticText(panel, wxID_ANY, wxT("Indexes change exist"), wxPoint(30,85));
+
+	wxStaticBitmap *bmpIndexMissing = new wxStaticBitmap(panel, wxID_ANY, *index_missing, wxPoint(280,85));
+	wxStaticText *textIndexMissing = new wxStaticText(panel, wxID_ANY, wxT("Drop Index"), wxPoint(300,85));
+
+	wxStaticBitmap *bmpIndexPresent = new wxStaticBitmap(panel, wxID_ANY, *index_present, wxPoint(160,85));
+	wxStaticText *textIndexPresent = new wxStaticText(panel, wxID_ANY, wxT("Add Index"), wxPoint(180,85));
+
+
+	// showing constraints
+	//wxBitmap *constraints_changed = new wxBitmap(constraints_changed_sm_xpm);
+	//wxStaticBitmap *bmpConstraintsChanged = new wxStaticBitmap(panel, wxID_ANY, *constraints_changed, wxPoint(10,102));
+	//wxStaticText *sometext = new wxStaticText(this, wxID_ANY, _(“Hello world label”), wxPoint(100,100));
+
+	//wxStaticBitmap *bmpConstraintsChanged = new wxStaticBitmap(panel, wxID_ANY, *constraints_changed, wxPoint(10,85));
+	
+	return panel;
+}
+void dlgDbDiff::CreateSchemaTab(wxNotebook * parent)
+{
+	
+	this->grid = new wxGrid(parent, wxID_ANY, wxPoint(0,0), wxSize(360,180),
+                              wxWANTS_CHARS | wxSIMPLE_BORDER);
+	
+    // grid initial config
+	grid->CreateGrid(5,2);
+	grid->EnableDragGridSize(false);
+	grid->EnableEditing(false);
+
+	// setting grid columns labels
+	grid->SetColLabelValue(0,wxT("Diff Exist"));
+	grid->SetColLabelValue(1,wxT("Description"));
+
+	grid->SetColSize(0,70);
+	grid->SetColSize(1,200);
+
+	// setting grid rows labels
+	grid->SetRowLabelValue(0,wxT("Columns:"));
+	grid->SetRowLabelValue(1,wxT("Datatype:"));
+	grid->SetRowLabelValue(2,wxT("Keys:"));
+	grid->SetRowLabelValue(3,wxT("Unique:"));
+	grid->SetRowLabelValue(4,wxT("Indexes:"));
+
+	grid->SetDefaultCellAlignment(wxALIGN_LEFT,wxALIGN_CENTRE);
+	grid->SetColLabelSize(15);
+	grid->SetColMinimalWidth(0,70);
+	grid->SetColMinimalWidth(1,70);
+}
+
+void dlgDbDiff::Load(wxTreeItemId dbid,ctlTree * tree, bool firstTime=true)
+{
+	wxTreeItemId schemaroot,schemalist,tableroot,tablelist,viewroot,viewlist;
+	wxCookieType schrootcookie,schlistcookie,tabrootcookie,tablistcookie,viewrootcookie,viewlistcookie;
+
+	if(tree->HasChildren(dbid))
+	{
+		schemaroot = tree->GetFirstChild(dbid,schrootcookie);
+		schemalist = tree->GetFirstChild(schemaroot,schlistcookie);
+
+		// going through with schema list
+		while(schemalist)
+		{
+			pgObject *data = tree->GetObject(schemalist);
+			pgSchemaBase *schema = (pgSchemaBase *)data;
+			tree->RemoveDummyChild(schema);
+			
+			tree->AppendCollection(schema,tableFactory);
+			tree->AppendCollection(schema,viewFactory);
+			
+			// after appending tables the tree must have grown up
+			tableroot = tree->GetFirstChild(schemalist,tabrootcookie);
+			viewroot = tree->GetNextSibling(tableroot);
+			
+			// going through with tables list
+			tablelist = tree->GetFirstChild(tableroot,tablistcookie);
+			while(tablelist)
+			{
+				pgObject *data = tree->GetObject(tablelist);
+				pgTable *table = (pgTable*)data;
+				tree->RemoveDummyChild(table);
+
+				// appending childrens
+				tree->AppendCollection(table, columnFactory);
+				tree->AppendCollection(table, constraintFactory);
+				tree->AppendCollection(table, indexFactory);
+
+				tablelist = tree->GetNextChild(tableroot,tablistcookie);
+			}
+			
+			// going through with view list
+			viewlist = tree->GetFirstChild(viewroot,viewlistcookie);
+			while(viewlist)
+			{
+				pgObject *data = tree->GetObject(viewlist);
+				pgView *view = (pgView*)data;
+				tree->RemoveDummyChild(view);
+
+				// appending childrens
+				tree->AppendCollection(view,columnFactory);
+				tree->AppendCollection(view,ruleFactory);
+
+				viewlist = tree->GetNextChild(viewroot,viewlistcookie);
+			}
+			schemalist = tree->GetNextChild(schemaroot,schlistcookie);
+		}
+	}
+}
+
+
+void dlgDbDiff::RefreshTargetTree(wxTreeItemId dbid)
+{
+	// deleting all the elements of target tree
+	treectrltrgdb->DeleteChildren(dbid);
+
+	// recreating the tree
+	treectrltrgdb->AppendCollection((pgDatabase*)targetDb,schemaFactory);
+	this->Load(dbid,treectrltrgdb,false);
+	treectrltrgdb->Expand(dbid);
+	wxCookieType cookie;
+	wxTreeItemId schemasId = treectrltrgdb->GetFirstChild(dbid,cookie);
+	treectrltrgdb->Expand(schemasId);
+}
+
+void dlgDbDiff::Refresh(pgObject *data)
+{
+    //StartMsg(wxString::Format(_("Refreshing %s"), data->GetTranslatedTypeName().c_str()));
+    treectrltrgdb->Freeze();
+
+    wxTreeItemId currentItem=data->GetId();
+
+    // Scan the child nodes and make a list of those that are expanded
+    // This is not an exact science as node names may change etc.
+    wxArrayString expandedNodes;
+    GetExpandedChildNodes(currentItem, expandedNodes);
+
+    treectrltrgdb->DeleteChildren(currentItem);
+
+    // refresh information about the object
+    data->SetDirty();
+    
+    pgObject *newData = data->Refresh(treectrltrgdb, currentItem);
+
+    bool done = !data->GetConnection() || data->GetConnection()->GetStatus() == PGCONN_OK;
+    
+    /*if (newData != data)
+    {
+        wxLogInfo(wxT("Deleting %s %s for refresh"), data->GetTypeName().c_str(), data->GetQuotedFullIdentifier().c_str());
+
+        if (data == currentObject)
+            currentObject = newData;
+
+        if (newData)
+        {
+            wxLogInfo(wxT("Replacing with new node %s %s for refresh"), newData->GetTypeName().c_str(), newData->GetQuotedFullIdentifier().c_str());
+
+            newData->SetId(currentItem);    // not done automatically
+            browser->SetItemData(currentItem, newData);
+
+            delete data;
+        }
+        else
+        {
+            wxLogInfo(wxT("No object to replace: vanished after refresh."));
+            
+            // If the connection is dead, just return here
+            if (data->GetConnection()->GetStatus() != PGCONN_OK)
+            {
+                CheckAlive();
+                browser->Thaw();
+                return;
+            }
+    
+            wxTreeItemId delItem=currentItem;
+            currentItem=browser->GetItemParent(currentItem);
+            browser->SelectItem(currentItem);
+            browser->Delete(delItem);
+        }
+    }*/
+
+    if (currentItem)
+    {
+        execSelChange(currentItem);
+
+        // Attempt to expand any child nodes that were previously expanded
+        ExpandChildNodes(currentItem, expandedNodes);
+    }
+
+    treectrltrgdb->Thaw();
+    //EndMsg(done);
+}
+void dlgDbDiff::execSelChange(wxTreeItemId item)
+{
+    // Get the item data, and feed it to the relevant handler,
+    // cast as required.
+	pgObject * currentObject;
+    currentObject = treectrltrgdb->GetObject(item);
+
+    // If we didn't get an object, then we may have a right click, or 
+    // invalid click, so ignore.
+    if (!currentObject) return;
+     setDisplay(currentObject, 0, 0);
+}
+void dlgDbDiff::setDisplay(pgObject *data, ctlListView *props, ctlSQLBox *sqlbox)
+{
+    pgServer *server=0;
+    bool showTree;
+
+    pgaFactory *factory=data->GetFactory();
+    if (factory)
+    {
+        if (factory == &serverFactory)
+        {
+            server = (pgServer *)data;
+
+            data->ShowTree(0, treectrltrgdb, props, sqlbox);
+            showTree=false;
+        }
+        else
+            showTree=true;
+    }
+    else
+        showTree=false;
+
+    if (showTree)
+        data->ShowTree(0,treectrltrgdb, props, sqlbox);
+}
+void dlgDbDiff::GetExpandedChildNodes(wxTreeItemId node, wxArrayString &expandedNodes)
+{
+    wxTreeItemIdValue cookie;
+    wxTreeItemId child = treectrltrgdb->GetFirstChild(node, cookie);
+
+    while (child.IsOk())
+    {
+        if (treectrltrgdb->IsExpanded(child))
+        {
+            GetExpandedChildNodes(child, expandedNodes);
+            expandedNodes.Add(GetNodePath(child));
+        }
+
+        child = treectrltrgdb->GetNextChild(node, cookie);
+    }
+}
+wxString dlgDbDiff::GetNodePath(wxTreeItemId node)
+{
+    wxString path;
+    path = treectrltrgdb->GetItemText(node).BeforeFirst('(');
+
+    wxTreeItemId parent = treectrltrgdb->GetItemParent(node);
+    while (parent.IsOk())
+    {
+        path = treectrltrgdb->GetItemText(parent).BeforeFirst('(') + wxT("/") + path;
+        parent = treectrltrgdb->GetItemParent(parent);
+    }
+
+    return path;
+}
+void dlgDbDiff::ExpandChildNodes(wxTreeItemId node, wxArrayString &expandedNodes)
+{
+    wxTreeItemIdValue cookie;
+    wxTreeItemId child = treectrltrgdb->GetFirstChild(node, cookie);
+
+    while (child.IsOk())
+    {
+        if (expandedNodes.Index(GetNodePath(child)) != wxNOT_FOUND)
+        {
+            treectrltrgdb->Expand(child);
+            ExpandChildNodes(child, expandedNodes);
+        }
+
+        child = treectrltrgdb->GetNextChild(node, cookie);
+    }
+}
+void dlgDbDiff::OnSrcGetSelection(wxTreeEvent &event)
+{
+
+	if(!diffSys->IsSync()) // only work before sync
+	{
+		TableScript *tabScr;
+		TableDiff *srcTable;
+		TableDiff *trgTable;
+
+		wxTreeItemId item = event.GetItem();
+		pgObject *data = treectrltrgdb->GetObject(item);
+		if (!data)
+			return;
+		if(data->IsCreatedBy(tableFactory))
+		{
+			if(!data->IsCollection())
+			{
+				notebook->SetSelection(1);
+				bool diffExist=false;
+				diffExist = diffSys->ShowDiffGrid(data,grid);
+				
+				tabScr = diffSys->GetTableScriptHandle();
+				wxString n1=((pgTable*)data)->GetName();
+				wxString n2 = ((pgTable*)data)->GetName(); 
+				srcTable = (TableDiff*)diffSys->GetSrcTableObject(data->GetSchema()->GetName(),((pgTable*)data)->GetName());
+				trgTable = (TableDiff*)diffSys->GetTrgTableObject(data->GetSchema()->GetName(),((pgTable*)data)->GetName());
+
+				if(diffExist && srcTable && trgTable) 
+				{
+					// always create a new as the old instance is destroyed
+					this->dViewer = new dlgDiffObjectViewer(this);
+
+					this->dViewer->Initialize(srcTable,trgTable,tabScr);
+					diffViewerBtn->Enable();
+				}
+			}
+			else
+				diffViewerBtn->Disable();
+		}
+		else
+		{
+			notebook->SetSelection(0);
+			diffViewerBtn->Disable();
+		}
+	}
+	else
+		diffViewerBtn->Disable();
+}
\ No newline at end of file
diff --git a/pgadmin/sv/dlgDiffObjectViewer.cpp b/pgadmin/sv/dlgDiffObjectViewer.cpp
new file mode 100644
index 0000000..32418fc
--- /dev/null
+++ b/pgadmin/sv/dlgDiffObjectViewer.cpp
@@ -0,0 +1,579 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: dlgDiffObjectViewer.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dlgDiffObjectViewer.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+#include "sv/dlgDiffObjectViewer.h"
+#include "sv/svDiffObject.h"
+#include "sv/svTableDiff.h"
+#include "sv/svColumnDiff.h"
+#include "sv/svPkDiff.h"
+#include "sv/svFkDiff.h"
+#include "sv/svIndexDiff.h"
+#include "sv/svUniqueDiff.h"
+#include "sv/svAlterColumn.h"
+
+
+BEGIN_EVENT_TABLE(dlgDiffObjectViewer, wxDialog)
+    EVT_BUTTON(XRCID("ID_BTN_SYNC_STD"),dlgDiffObjectViewer::ApplySelChanges )
+	EVT_CLOSE(dlgDiffObjectViewer::DialogClose)
+END_EVENT_TABLE()
+
+
+
+// images header
+#include "images/sv/green.xpm"
+#include "images/sv/red.xpm"
+#include "images/sv/white.xpm"
+#include "images/sv/yellow.xpm"
+
+dlgDiffObjectViewer::dlgDiffObjectViewer(dlgDbDiff *parentDialog)
+{
+	this->dlgParent = (wxWindow*)parentDialog;
+	this->LoadResource(dlgParent,wxT("dlgDiffObjectViewer")); 
+	this->SetImages();
+	ROWS=5;
+	sourceObjGrid=NULL;
+	targetObjGrid=NULL;
+}
+void dlgDiffObjectViewer::Initialize(DiffObject * selSrcTable,DiffObject * selTrgTable,TableScript * tabScr)
+{
+	// getting the selected tables + diff
+	srcTable = selSrcTable;
+	trgTable = selTrgTable;
+	tableScr = tabScr;
+
+	wxString sourceObjFullName = wxT("Source| Server:") + ((TableDiff*)selSrcTable)->GetTable()->GetServer()->GetFullName()+
+		+wxT(" | Table:")+((TableDiff*)selSrcTable)->GetTable()->GetName();
+
+	wxString targetObjFullName = wxT("Target| Server:") + ((TableDiff*)selTrgTable)->GetTable()->GetServer()->GetFullName()+
+		+wxT(" | Table:")+((TableDiff*)selTrgTable)->GetTable()->GetName();
+
+
+	wxNotebook *srcObj = XRCCTRL(*(this), "ID_NTB_SRCOBJ", wxNotebook);
+	wxNotebook *trgObj = XRCCTRL(*(this), "ID_NTB_TRGOBJ", wxNotebook);
+	wxNotebook *trgObjAfter = XRCCTRL(*(this), "ID_NTB_TRG_AFTER", wxNotebook);
+	
+	srcObj->SetPageText(0,sourceObjFullName);
+	trgObj->SetPageText(0,targetObjFullName);
+	trgObjAfter->SetPageText(0,targetObjFullName+wxT(" (After Sync) "));
+}
+void dlgDiffObjectViewer::SettingBeforeGrid(size_t srcColCount,size_t trgColCount)
+{
+	sourceObjGrid = XRCCTRL(*this, "ID_GRID_SRCOBJ", wxGrid);
+	targetObjGrid = XRCCTRL(*this, "ID_GRID_TRGOBJ", wxGrid);
+	sourceObjGrid->CreateGrid(ROWS,srcColCount);
+	targetObjGrid->CreateGrid(ROWS,trgColCount);
+
+	
+	// source grid conf
+	sourceObjGrid->EnableDragGridSize(false);
+	//sourceObjGrid->EnableEditing(false);
+	sourceObjGrid->SetDefaultCellAlignment(wxALIGN_CENTRE,wxALIGN_CENTRE);
+	sourceObjGrid->SetColLabelSize(25);
+	sourceObjGrid->SetColSize(0,70);
+
+	
+	// setting grid rows labels
+	sourceObjGrid->SetRowLabelValue(DATATYPE,wxT("DataType"));
+	sourceObjGrid->SetRowLabelValue(PRIMARYKEY,wxT("Primary Key"));
+	sourceObjGrid->SetRowLabelValue(FOREIGNKEY,wxT("Foreign Key"));
+	sourceObjGrid->SetRowLabelValue(NOTNULL,wxT("Not Null"));
+	sourceObjGrid->SetRowLabelValue(INDEX,wxT("Index"));
+
+	
+	targetObjGrid->EnableDragGridSize(false);
+	//targetObjGrid->EnableEditing(false);
+	targetObjGrid->SetDefaultCellAlignment(wxALIGN_CENTRE,wxALIGN_CENTRE);
+	targetObjGrid->SetColLabelSize(25);
+	targetObjGrid->SetColSize(0,70);
+
+	// setting grid rows labels
+	targetObjGrid->SetRowLabelValue(DATATYPE,wxT("DataType"));
+	targetObjGrid->SetRowLabelValue(PRIMARYKEY,wxT("Primary Key"));
+	targetObjGrid->SetRowLabelValue(FOREIGNKEY,wxT("Foreign Key"));
+	targetObjGrid->SetRowLabelValue(NOTNULL,wxT("Not Null"));
+	targetObjGrid->SetRowLabelValue(INDEX,wxT("Index"));
+
+}
+void dlgDiffObjectViewer::SettingAfterGrid(size_t ColCount)
+{
+	targetAfterGrid = XRCCTRL(*this, "ID_GRID_TRG_AFTER", wxGrid);
+
+	targetAfterGrid->CreateGrid(ROWS,ColCount);
+	
+	// target grid conf
+	targetAfterGrid->EnableDragGridSize(false);
+	sourceObjGrid->EnableEditing(false);
+	targetAfterGrid->SetDefaultCellAlignment(wxALIGN_CENTRE,wxALIGN_CENTRE);
+	targetAfterGrid->SetColLabelSize(25);
+	targetAfterGrid->SetColSize(0,70);
+
+	// setting grid rows labels
+	targetAfterGrid->SetRowLabelValue(DATATYPE,wxT("DataType"));
+	targetAfterGrid->SetRowLabelValue(PRIMARYKEY,wxT("Primary Key"));
+	targetAfterGrid->SetRowLabelValue(FOREIGNKEY,wxT("Foreign Key"));
+	targetAfterGrid->SetRowLabelValue(NOTNULL,wxT("Not Null"));
+	targetAfterGrid->SetRowLabelValue(INDEX,wxT("Index"));
+
+}
+void dlgDiffObjectViewer::RenderBeforeDifference()
+{
+	size_t srcColumnsCount=((TableDiff*)srcTable)->GetColumnObjList().GetCount();
+	size_t trgColumnsCount=((TableDiff*)trgTable)->GetColumnObjList().GetCount();
+	
+	SettingBeforeGrid(srcColumnsCount,trgColumnsCount);
+	RenderColumnsBeforeDiff();
+	RenderIndexBeforeDiff();
+	RenderCellDifference();
+
+	RenderAfterDifference();
+	Show();
+}
+void dlgDiffObjectViewer::RenderCellDifference()
+{
+	for(size_t i=0; i<trgColMapping.GetCount();i++)
+	{
+		MappingColObj *trgMapCol = trgColMapping.Item(i);
+		MappingColObj *srcMapCol = this->srcSearchColMap(trgMapCol->GetColName().Trim(false));
+
+		if(srcMapCol->GetColType()==COLORG && trgMapCol->GetColType()==COLORG)
+		{
+			// checking diff
+			wxString src = srcMapCol->GetColName();
+			wxString trg = trgMapCol->GetColName();
+			if(srcMapCol->GetDataType()!=trgMapCol->GetDataType())
+			{
+				SetCellBgYellow(DATATYPE,srcMapCol->GetGridColId(),sourceObjGrid);
+				SetCellBgYellow(DATATYPE,trgMapCol->GetGridColId(),targetObjGrid);
+			}
+			
+			if(srcMapCol->GetPk()!=trgMapCol->GetPk())
+			{
+				SetCellBgYellow(PRIMARYKEY,srcMapCol->GetGridColId(),sourceObjGrid);
+				SetCellBgYellow(PRIMARYKEY,trgMapCol->GetGridColId(),targetObjGrid);
+			}
+			if(srcMapCol->GetFk()!=trgMapCol->GetFk())
+			{
+				SetCellBgYellow(FOREIGNKEY,srcMapCol->GetGridColId(),sourceObjGrid);
+				SetCellBgYellow(FOREIGNKEY,trgMapCol->GetGridColId(),targetObjGrid);
+			}
+			if(srcMapCol->GetNotNull()!=trgMapCol->GetNotNull())
+			{
+				SetCellBgYellow(NOTNULL,srcMapCol->GetGridColId(),sourceObjGrid);
+				SetCellBgYellow(NOTNULL,trgMapCol->GetGridColId(),targetObjGrid);
+			}
+			if(srcMapCol->IsIndexSet()!=trgMapCol->IsIndexSet())
+			{
+				SetCellBgYellow(INDEX,srcMapCol->GetGridColId(),sourceObjGrid);
+				SetCellBgYellow(INDEX,trgMapCol->GetGridColId(),targetObjGrid);
+			}
+		}
+	}
+}
+
+void dlgDiffObjectViewer::RenderAfterDifference()
+{
+	int colCount = trgColMapping.GetCount(); 
+	SettingAfterGrid(colCount);
+	PopulateAfterColumns();
+	//RenderAlterBeforeDiff();
+}
+void dlgDiffObjectViewer::PopulateAfterColumns()
+{
+	// rendering source table
+	for(size_t i=0; i<trgColMapping.GetCount();i++)
+	{
+		MappingColObj * mapCol = trgColMapping.Item(i);
+		
+		this->targetAfterGrid->SetColLabelValue(mapCol->GetGridColId(),mapCol->GetColName());
+
+		this->targetAfterGrid->SetCellValue(DATATYPE,mapCol->GetGridColId(),mapCol->GetDataType());
+		if(mapCol->GetPk())
+			this->targetAfterGrid->SetCellValue(PRIMARYKEY,mapCol->GetGridColId(),wxT("Yes"));
+		else
+			this->targetAfterGrid->SetCellValue(PRIMARYKEY,mapCol->GetGridColId(),wxT("No"));
+
+		if(mapCol->GetFk())
+			this->targetAfterGrid->SetCellValue(FOREIGNKEY,mapCol->GetGridColId(),wxT("Yes"));
+		else
+			this->targetAfterGrid->SetCellValue(FOREIGNKEY,mapCol->GetGridColId(),wxT("No"));
+
+		if(mapCol->GetNotNull())
+			this->targetAfterGrid->SetCellValue(NOTNULL,mapCol->GetGridColId(),wxT("Yes"));
+		else
+			this->targetAfterGrid->SetCellValue(NOTNULL,mapCol->GetGridColId(),wxT("No"));
+
+		if(mapCol->IsIndexSet())
+			this->targetAfterGrid->SetCellValue(INDEX,mapCol->GetGridColId(),mapCol->GetIndexType());
+
+		if(mapCol->GetColType() == COLADD)
+			SetColBgGreen(mapCol->GetGridColId(),targetAfterGrid);
+		else if(mapCol->GetColType() == COLDROP)
+			SetColBgRed(mapCol->GetGridColId(),targetAfterGrid);
+	}
+}
+void dlgDiffObjectViewer::RenderIndexBeforeDiff()
+{
+	size_t srcIndexCount=((TableDiff*)srcTable)->GetIndexObjList().GetCount();
+	size_t trgIndexCount=((TableDiff*)trgTable)->GetIndexObjList().GetCount();
+
+	for(size_t i=0; i<srcIndexCount;i++)
+	{
+		IndexDiff* indDiff= (IndexDiff*)((TableDiff*)srcTable)->GetIndexObjList().Item(i);
+		pgIndex *index = indDiff->GetIndex();
+		index->ReadIndexColumnInfo();
+		
+		wxString indexColumns = index->GetColumns();
+		wxStringTokenizer indCols(indexColumns,wxT(","));
+		while (indCols.HasMoreTokens())
+		{
+			wxString colName=indCols.GetNextToken();
+			MappingColObj *srcMapObj = this->srcSearchColMap(colName.Trim(false));
+
+			srcMapObj->SetIndex(true);
+			srcMapObj->SetIndexType(index->GetIndexType());
+			this->sourceObjGrid->SetCellValue(INDEX,srcMapObj->GetGridColId(),index->GetIndexType());
+
+			// only for target as its not 2 way 
+			MappingColObj *trgMapObj = this->trgSearchColMap(colName.Trim(false));
+			trgMapObj->SetIndex(true);
+			trgMapObj->SetIndexType(index->GetIndexType());
+			this->targetObjGrid->SetCellValue(INDEX,trgMapObj->GetGridColId(),index->GetIndexType());
+		}
+	}
+	for(size_t i=0; i<trgIndexCount;i++)
+	{
+		IndexDiff* indDiff= (IndexDiff*)((TableDiff*)trgTable)->GetIndexObjList().Item(i);
+		pgIndex *index = indDiff->GetIndex();
+		index->ReadIndexColumnInfo();
+		
+		wxString indexColumns = index->GetColumns();
+		wxStringTokenizer indCols(indexColumns,wxT(","));
+		while (indCols.HasMoreTokens())
+		{
+			wxString colName=indCols.GetNextToken();
+			MappingColObj *mapObj = this->trgSearchColMap(colName.Trim(false));
+
+			mapObj->SetIndex(true);
+			mapObj->SetIndexType(index->GetIndexType());
+			this->targetObjGrid->SetCellValue(INDEX,mapObj->GetGridColId(),index->GetIndexType());
+			
+		}
+	}
+}
+void dlgDiffObjectViewer::RenderColumnsBeforeDiff()
+{
+	MappingColObj *mapCol;
+	
+	size_t srcColumnsCount=((TableDiff*)srcTable)->GetColumnObjList().GetCount();
+	size_t trgColumnsCount=((TableDiff*)trgTable)->GetColumnObjList().GetCount();
+
+	int srcColId = srcColumnsCount;
+	int trgColId = trgColumnsCount;
+		
+	ColumnScript * colScr = tableScr->GetColumnScript();
+
+	PopulateBeforeColumns();
+	// Getting list of add columns/remove/alter columns
+	for(size_t i=0; i<colScr->GetColumnList().GetCount();i++)
+	{
+		ColumnElement* colElem= colScr->GetColumnList().Item(i);
+		if(colElem->GetMetaType()==ADDCOLUMN && 
+			colElem->GetTableName()==srcTable->GetObject()->GetName() &&
+			colElem->GetSchemaName() == srcTable->GetObject()->GetSchema()->GetName())
+		{
+			
+			wxString colname=colElem->GetColumnName();
+			
+			// background changes at source end
+			MappingColObj *mco = this->srcSearchColMap(colElem->GetColumnName());
+			if(mco)
+				SetColBgGreen(mco->GetGridColId(),sourceObjGrid);
+
+			// adding the (missing)column at target
+			wxString n= mco->GetColName();
+			this->targetObjGrid->InsertCols(trgColId,1);
+			targetObjGrid->SetColLabelValue(trgColId,mco->GetColName());
+			this->targetObjGrid->SetCellValue(DATATYPE,trgColId,mco->GetDataType());
+			
+			if(mco->GetPk())
+			{
+				//wxGridCellBoolEditor::UseStringValues(wxT("1"),wxT("0"));
+				this->targetObjGrid->SetCellValue(PRIMARYKEY,trgColId,wxT("Yes"));
+				//wxGridCellBoolRenderer *bren = new wxGridCellBoolRenderer()
+				//this->targetObjGrid->SetCellRenderer(PRIMARYKEY, trgColId, new wxGridCellBoolRenderer);
+				//this->targetObjGrid->SetCellEditor(PRIMARYKEY, trgColId, new wxGridCellBoolEditor);
+			}
+			else
+				this->targetObjGrid->SetCellValue(PRIMARYKEY,trgColId,wxT("No"));
+
+			if(mco->GetFk())
+				this->targetObjGrid->SetCellValue(FOREIGNKEY,trgColId,wxT("Yes"));
+			else
+				this->targetObjGrid->SetCellValue(FOREIGNKEY,trgColId,wxT("No"));
+
+			if(mco->GetNotNull())
+				this->targetObjGrid->SetCellValue(NOTNULL,trgColId,wxT("Yes"));
+			else
+				this->targetObjGrid->SetCellValue(NOTNULL,trgColId,wxT("No"));
+	
+			// background changes at target end
+			SetColBgRed(trgColId,targetObjGrid);
+			
+			// saving the new entry
+			mapCol = new MappingColObj();
+			mapCol->SetColName(colElem->GetColumnName());
+			mapCol->SetGridColId(trgColId);
+			mapCol->SetDataType(mco->GetDataType());
+			mapCol->SetPk(mco->GetPk());
+			mapCol->SetFk(mco->GetFk());
+			mapCol->SetNotNull(mco->GetNotNull());
+			mapCol->SetColType(COLADD); // this is only for the target as not catering for 2 way case now
+			this->trgColMapping.Add(mapCol); 
+			trgColId++;
+		}
+		else if(colElem->GetMetaType()==DROPCOLUMN && 
+			colElem->GetTableName()==srcTable->GetObject()->GetName() &&
+			colElem->GetSchemaName() == srcTable->GetObject()->GetSchema()->GetName())
+		{
+			// background changes at source end
+			MappingColObj *mco = this->trgSearchColMap(colElem->GetColumnName());
+			// setting this column as dropped one
+			
+			if(mco)
+				SetColBgGreen(mco->GetGridColId(),targetObjGrid);
+			mco->SetColType(COLDROP);
+			
+			// adding the (missing)columns at source end
+			this->sourceObjGrid->InsertCols(srcColId,1);
+			sourceObjGrid->SetColLabelValue(srcColId,mco->GetColName());
+			this->sourceObjGrid->SetCellValue(DATATYPE,srcColId,mco->GetDataType());
+
+			if(mco->GetPk())
+				this->sourceObjGrid->SetCellValue(PRIMARYKEY,srcColId,wxT("Yes"));
+			else
+				this->sourceObjGrid->SetCellValue(PRIMARYKEY,srcColId,wxT("No"));
+
+			if(mco->GetFk())
+				this->sourceObjGrid->SetCellValue(FOREIGNKEY,srcColId,wxT("Yes"));
+			else
+				this->sourceObjGrid->SetCellValue(FOREIGNKEY,srcColId,wxT("No"));
+
+			if(mco->GetNotNull())
+				this->sourceObjGrid->SetCellValue(NOTNULL,srcColId,wxT("Yes"));
+			else
+				this->sourceObjGrid->SetCellValue(NOTNULL,srcColId,wxT("No"));
+
+			SetColBgRed(srcColId,sourceObjGrid);
+
+			mapCol = new MappingColObj();
+			mapCol->SetColName(colElem->GetColumnName());
+			
+			mapCol->SetGridColId(srcColId);
+			mapCol->SetDataType(mco->GetDataType());
+			mapCol->SetPk(mco->GetPk());
+			mapCol->SetFk(mco->GetFk());
+			mapCol->SetNotNull(mco->GetNotNull());
+			this->srcColMapping.Add(mapCol); // saving at the src map
+			srcColId++;
+		}
+	}
+}
+void dlgDiffObjectViewer::PopulateBeforeColumns()
+{
+	size_t srcColumnsCount=((TableDiff*)srcTable)->GetColumnObjList().GetCount();
+	size_t trgColumnsCount=((TableDiff*)trgTable)->GetColumnObjList().GetCount();
+
+	MappingColObj *mapCol;
+	
+	// rendering source table
+	for(size_t i=0; i<srcColumnsCount;i++)
+	{
+		ColumnDiff* col= (ColumnDiff*)((TableDiff*)srcTable)->GetColumnObjList().Item(i);
+		mapCol = new MappingColObj();
+
+		// getting column info
+		wxString name = col->GetObject()->GetName();
+		this->sourceObjGrid->SetColLabelValue(i,name);
+		this->sourceObjGrid->SetCellValue(DATATYPE,i,col->GetColumn()->GetVarTypename());
+		mapCol->SetDataType(col->GetColumn()->GetVarTypename());
+
+		// getting column pk info
+		col->GetColumn()->SetPK(); // not depending of tree details to do this
+		bool test = col->GetColumn()->GetIsPK();
+		if(col->GetColumn()->GetIsPK())
+		{
+			this->sourceObjGrid->SetCellValue(PRIMARYKEY,i,wxT("Yes"));
+			mapCol->SetPk(true);
+		}
+		else
+		{
+			this->sourceObjGrid->SetCellValue(PRIMARYKEY,i,wxT("No"));
+			mapCol->SetPk(false);
+		}
+		// getting column fk info
+		if(col->GetColumn()->GetIsFK())
+		{
+			this->sourceObjGrid->SetCellValue(FOREIGNKEY,i,wxT("Yes"));
+			mapCol->SetFk(true);
+		}
+		else
+		{
+			this->sourceObjGrid->SetCellValue(FOREIGNKEY,i,wxT("No"));
+			mapCol->SetFk(false);
+		}
+
+		// getting column not null info
+		if(col->GetColumn()->GetNotNull())
+		{
+			this->sourceObjGrid->SetCellValue(NOTNULL,i,wxT("Yes"));
+			mapCol->SetNotNull(true);
+		}
+		else
+		{
+			this->sourceObjGrid->SetCellValue(NOTNULL,i,wxT("No"));
+			mapCol->SetNotNull(false);
+		}
+		mapCol->SetColName(name);
+		mapCol->SetGridColId(i);
+		mapCol->SetColType(COLORG);
+		this->srcColMapping.Add(mapCol);
+	}
+
+	// rendering target table
+	for(size_t i=0; i<trgColumnsCount;i++)
+	{
+		mapCol = new MappingColObj();
+
+		ColumnDiff* col= (ColumnDiff*)((TableDiff*)trgTable)->GetColumnObjList().Item(i);
+		wxString name = col->GetObject()->GetName();
+		
+		// getting column info
+		this->targetObjGrid->SetColLabelValue(i,name);
+		this->targetObjGrid->SetCellValue(DATATYPE,i,col->GetColumn()->GetVarTypename());
+		mapCol->SetDataType(col->GetColumn()->GetVarTypename());
+
+		// getting column pk info
+		col->GetColumn()->SetPK(); // not depending of tree details to do this
+		if(col->GetColumn()->GetIsPK())
+		{
+			this->targetObjGrid->SetCellValue(PRIMARYKEY,i,wxT("Yes"));
+			mapCol->SetPk(true);
+		}
+		else
+		{
+			this->targetObjGrid->SetCellValue(PRIMARYKEY,i,wxT("No"));
+			mapCol->SetPk(false);
+		}
+
+		// getting column fk info
+		if(col->GetColumn()->GetIsFK())
+		{
+			this->targetObjGrid->SetCellValue(FOREIGNKEY,i,wxT("Yes"));
+			mapCol->SetFk(true);
+		}
+		else
+		{
+			this->targetObjGrid->SetCellValue(FOREIGNKEY,i,wxT("No"));
+			mapCol->SetFk(false);
+		}
+		// getting column not null info
+		if(col->GetColumn()->GetNotNull())
+		{
+			this->targetObjGrid->SetCellValue(NOTNULL,i,wxT("Yes"));
+			mapCol->SetNotNull(true);
+		}
+		else
+		{
+			this->targetObjGrid->SetCellValue(NOTNULL,i,wxT("No"));
+			mapCol->SetNotNull(false);
+		}
+		mapCol->SetColName(name);
+		mapCol->SetGridColId(i);
+		mapCol->SetColType(COLORG);
+		this->trgColMapping.Add(mapCol);
+	}
+}
+void dlgDiffObjectViewer::SetImages()
+{
+	wxBitmap * bmpColMissing = new wxBitmap(red_xpm);
+	wxBitmap * bmpColPresent = new wxBitmap(green_xpm);
+	wxBitmap * bmpOtherChanges = new wxBitmap(yellow_xpm);
+	wxBitmap * bmpNoChanges = new wxBitmap(white_xpm);
+
+	wxStaticBitmap * colMissingBefore = XRCCTRL(*(this), "wxID_BMP_COLPRES", wxStaticBitmap);
+	colMissingBefore->SetBitmap(*bmpColPresent);
+	
+	wxStaticBitmap * colPresentBefore = XRCCTRL(*(this), "wxID_BMP_COLMISS", wxStaticBitmap);
+	colPresentBefore->SetBitmap(*bmpColMissing);
+	
+	wxStaticBitmap * otherChangeBefore = XRCCTRL(*(this), "wxID_BMP_OTHER", wxStaticBitmap);
+	otherChangeBefore->SetBitmap(*bmpOtherChanges);
+
+	wxStaticBitmap * noChangeBefore = XRCCTRL(*(this), "wxID_BMP_NOCHG", wxStaticBitmap);
+	noChangeBefore->SetBitmap(*bmpNoChanges);
+
+	wxStaticBitmap * colMissingAfter = XRCCTRL(*(this), "wxID_BMP_AFTER_COLADD", wxStaticBitmap);
+	colMissingAfter->SetBitmap(*bmpColPresent);
+	
+	wxStaticBitmap * colPresentAfter = XRCCTRL(*(this), "wxID_BMP_AFTER_COLDROP", wxStaticBitmap);
+	colPresentAfter->SetBitmap(*bmpColMissing);
+
+	wxStaticBitmap * noChangeAfter = XRCCTRL(*(this), "wxID_BMP_AFTER_NOCHG", wxStaticBitmap);
+	noChangeAfter->SetBitmap(*bmpNoChanges);
+}
+dlgDiffObjectViewer::~dlgDiffObjectViewer()
+{
+}
+void dlgDiffObjectViewer::ApplySelChanges(wxCommandEvent& event)
+{
+}
+void dlgDiffObjectViewer::DialogClose(wxCloseEvent &event)
+{
+	Destroy();
+}
+MappingColObj *dlgDiffObjectViewer::srcSearchColMap(wxString colName)
+{
+	for(size_t i=0 ; i< srcColMapping.GetCount();i++)
+	{
+		MappingColObj * mco = srcColMapping.Item(i);
+		if(mco->GetColName()==colName)
+			return mco;
+	}
+	return 0;		
+}
+MappingColObj *dlgDiffObjectViewer::trgSearchColMap(wxString colName)
+{
+	for(size_t i=0 ; i< trgColMapping.GetCount();i++)
+	{
+		MappingColObj * mco = trgColMapping.Item(i);
+		if(mco->GetColName()==colName)
+			return mco;
+	}
+	return 0;		
+}
+void dlgDiffObjectViewer::SetColBgGreen(int colId,wxGrid * grid)
+{
+	wxColour colour(132,153,62);
+	for(int i=0; i<ROWS ; i++)
+		grid->SetCellBackgroundColour(i,colId,colour);
+}
+void dlgDiffObjectViewer::SetColBgRed(int colId,wxGrid *grid)
+{
+	wxColour colour(209,128,127);
+	for(int i=0; i<ROWS ; i++)
+		grid->SetCellBackgroundColour(i,colId,colour);
+}
+void dlgDiffObjectViewer::SetCellBgYellow(int row , int cellId,wxGrid *grid)
+{
+	wxColour colour(235,233,148);
+	grid->SetCellBackgroundColour(row,cellId,colour);
+}
diff --git a/pgadmin/sv/module.mk b/pgadmin/sv/module.mk
new file mode 100644
index 0000000..c6a569a
--- /dev/null
+++ b/pgadmin/sv/module.mk
@@ -0,0 +1,36 @@
+#######################################################################
+#
+# pgAdmin III - PostgreSQL Tools
+# $Id: module.mk 8189 2010-02-25 22:10:21Z dpage $
+# Copyright (C) 2002 - 2009, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# module.mk - pgadmin/sv/ Makefile fragment
+#
+#######################################################################
+
+pgadmin3_SOURCES += \
+	$(srcdir)/sv/dlgAuthServer.cpp \
+	$(srcdir)/sv/dlgDbDiff.cpp \
+	$(srcdir)/sv/svAddColumn.cpp \
+	$(srcdir)/sv/svAddIndex.cpp \
+	$(srcdir)/sv/svAddSchema.cpp \
+	$(srcdir)/sv/svAddTable.cpp \
+	$(srcdir)/sv/svColumnDiff.cpp \
+	$(srcdir)/sv/svConstraintDiff.cpp \
+	$(srcdir)/sv/svDbDiff.cpp \
+        $(srcdir)/sv/svDiffElement.cpp \
+	$(srcdir)/sv/svDropColumn.cpp \
+	$(srcdir)/sv/svFKDiff.cpp \
+	$(srcdir)/sv/svIndexDiff.cpp \
+	$(srcdir)/sv/svPKDiff.cpp \
+	$(srcdir)/sv/svSchemaDiff.cpp \
+	$(srcdir)/sv/svTableDiff.cpp \
+	$(srcdir)/sv/svUniqueDiff.cpp \
+	$(srcdir)/sv/svViewDiff.cpp \
+	$(srcdir)/sv/svDiffObject.cpp
+
+EXTRA_DIST += \
+    $(srcdir)/sv/module.mk
+
+
diff --git a/pgadmin/sv/svAddColumn.cpp b/pgadmin/sv/svAddColumn.cpp
new file mode 100644
index 0000000..a2c48f1
--- /dev/null
+++ b/pgadmin/sv/svAddColumn.cpp
@@ -0,0 +1,50 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAddColumn.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAddColumn.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgColumn.h"
+#include "sv/svAddColumn.h"
+#include "sv/svColumnDiff.h"
+#include "sv/svDiffSystem.h"
+
+AddColumn::AddColumn(DiffObject * obj)
+{
+	column = ((ColumnDiff *)obj)->GetColumn();
+	SetColumnName(column->GetName());
+	SetTableName(column->GetTable()->GetName());
+	SetSchemaName(column->GetSchema()->GetName());
+	SetVarTypeName(column->GetVarTypename());
+	column->SetPK(); // initializing the column PK
+	SetIsPK(column->GetIsPK());
+	SetIsFK(column->GetIsFK());
+	SetNotNull(column->GetNotNull());
+	SetMetaType(ADDCOLUMN);
+}
+
+void AddColumn::GenerateScript()
+{
+	wxString sqlScript;
+	sqlScript+=wxT(" ALTER TABLE ")+column->GetQuotedFullTable()+
+				wxT(" ADD COLUMN \"")+
+				GetColumnName()+wxT("\" ")+ column->GetQuotedTypename()+wxT(";\n");
+	
+	sqlScript+=wxT(" ALTER TABLE ")+column->GetQuotedFullTable()+
+				wxT(" ALTER COLUMN \"")+
+				GetColumnName()+wxT("\" SET STORAGE ")+column->GetDefaultStorage()+wxT(";\n");
+	if(column->GetNotNull())
+	{
+		sqlScript+=wxT(" ALTER TABLE ")+column->GetQuotedFullTable()+ 
+			wxT(" ALTER COLUMN \"")+
+			GetColumnName()+wxT("\" ")+wxT(" SET NOT NULL;\n ");
+	}
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svAddFk.cpp b/pgadmin/sv/svAddFk.cpp
new file mode 100644
index 0000000..a44c35b
--- /dev/null
+++ b/pgadmin/sv/svAddFk.cpp
@@ -0,0 +1,40 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAddFk.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAddFk.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgForeignKey.h"
+#include "sv/svAddFk.h"
+#include "sv/svFkDiff.h"
+#include "sv/svDiffSystem.h"
+
+
+AddFk::AddFk(DiffObject * obj){
+	fk = ((FkDiff *)obj)->GetFk();
+	SetFkName(fk->GetName());
+	SetSchemaName(fk->GetSchema()->GetName());
+	SetTableName(fk->GetTable()->GetName());
+	SetMetaType(ADDFK);
+}
+
+void AddFk::GenerateScript()
+{
+	wxString sqlScript;
+	fk->ReadFkColumnInfo();
+	
+	
+	sqlScript +=wxT(" ALTER TABLE ")+fk->GetSchema()->GetName()+wxT(".")+fk->GetTable()->GetName()+
+				wxT(" ADD CONSTRAINT ")+ GetFkName() + wxT(" FOREIGN KEY ")+ fk->GetDefinition();
+	SetScript(sqlScript);
+}
+void AddFk::ApplyScript()
+{
+}
diff --git a/pgadmin/sv/svAddIndex.cpp b/pgadmin/sv/svAddIndex.cpp
new file mode 100644
index 0000000..a7b847a
--- /dev/null
+++ b/pgadmin/sv/svAddIndex.cpp
@@ -0,0 +1,37 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAddIndex.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAddIndex.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgIndex.h"
+#include "sv/svAddIndex.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svIndexDiff.h"
+
+AddIndex::AddIndex(DiffObject * obj)
+{
+	index = ((IndexDiff *)obj)->GetIndex();;
+	SetIndexName(index->GetName());
+	SetTableName(index->GetTable()->GetName());
+	SetSchemaName(index->GetSchema()->GetName());
+	
+	SetMetaType(ADDINDEX);
+}
+void AddIndex::GenerateScript()
+{
+	wxString sqlScript;
+	index->ReadIndexColumnInfo();
+	sqlScript += index->GetCreate();
+	SetScript(sqlScript);
+}
+void AddIndex::ApplyScript()
+{
+}
diff --git a/pgadmin/sv/svAddPk.cpp b/pgadmin/sv/svAddPk.cpp
new file mode 100644
index 0000000..b3011da
--- /dev/null
+++ b/pgadmin/sv/svAddPk.cpp
@@ -0,0 +1,34 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: dlgAuthServer.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAddColumn.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgPrimaryKey.h"
+#include "sv/svAddPk.h"
+#include "sv/svPkDiff.h"
+
+
+AddPk::AddPk(DiffObject * obj){
+	pk = ((PkDiff *)obj)->GetPk();
+	SetPkName(pk->GetName());
+	SetSchemaName(pk->GetSchema()->GetName());
+	SetTableName(pk->GetTable()->GetName());
+	SetMetaType(ADDPK);
+}
+
+void AddPk::GenerateScript()
+{
+	wxString sqlScript;
+	pk->ReadPkColumnInfo();
+	sqlScript +=wxT(" ALTER TABLE ")+pk->GetSchema()->GetName()+wxT(".")+pk->GetTable()->GetName()+
+				wxT(" ADD CONSTRAINT ")+ GetPkName()+ wxT(" PRIMARY KEY ")+ pk->GetDefinition()+wxT(";");
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svAddUnique.cpp b/pgadmin/sv/svAddUnique.cpp
new file mode 100644
index 0000000..4603e32
--- /dev/null
+++ b/pgadmin/sv/svAddUnique.cpp
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: dlgAuthServer.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAddUnique.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgUnique.h"
+#include "sv/svAddUnique.h"
+#include "sv/svUniqueDiff.h"
+#include "sv/svDiffSystem.h"
+
+
+AddUnique::AddUnique(DiffObject * obj)
+{
+	unique= ((UniqueDiff *)obj)->GetUnique();
+	SetUniqueName(unique->GetName());
+	SetTableName(unique->GetTable()->GetName());
+	SetSchemaName(unique->GetSchema()->GetName());
+	
+	SetMetaType(ADDUNIQUE);
+}
+
+void AddUnique::GenerateScript()
+{
+	wxString sqlScript;
+	unique->ReadUniqueColumnInfo();
+
+	sqlScript+=wxT(" ALTER TABLE ")+unique->GetSchema()->GetName()+wxT(".")+unique->GetTable()->GetName()+
+				wxT(" ADD CONSTRAINT \"")+GetUniqueName()+ wxT("\" UNIQUE ") + unique->GetDefinition()+ wxT(";");
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svAlterColumn.cpp b/pgadmin/sv/svAlterColumn.cpp
new file mode 100644
index 0000000..a425cb0
--- /dev/null
+++ b/pgadmin/sv/svAlterColumn.cpp
@@ -0,0 +1,65 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterColumn.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterColumn.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgColumn.h"
+#include "sv/svAlterColumn.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svColumnDiff.h"
+
+
+AlterColumn::AlterColumn(DiffObject *obj)
+{
+	column = ((ColumnDiff*)obj)->GetColumn();
+	SetColumnName(column->GetName());
+	SetTableName(column->GetTable()->GetName());
+	SetSchemaName(column->GetSchema()->GetName());
+	SetMetaType(ALTERCOLUMN);
+	SetVarTypeName(column->GetVarTypename());
+	column->SetPK(); // initializing the column PK
+	SetIsPK(column->GetIsPK());
+	SetIsFK(column->GetIsFK());
+	SetNotNull(column->GetNotNull());
+	btypChange=false;
+	bdropNotNull=false;
+}
+void AlterColumn::GenerateScript()
+{
+	wxString sqlScript;
+	
+	// testing here what kind of differences are there
+	sqlScript+=wxT(" ALTER TABLE ")+column->GetQuotedFullTable()+
+				wxT(" ALTER COLUMN \"")+
+				GetColumnName()+wxT("\" TYPE ")+column->GetVarTypename()+wxT(";\n");
+
+	if(btypChange)
+		sqlScript+=wxT(" ALTER TABLE ")+column->GetQuotedFullTable()+
+				wxT(" ALTER COLUMN \"")+
+				GetColumnName()+wxT("\" SET STORAGE ")+column->GetStorage()+wxT(";\n");
+	if(bdropNotNull)
+		sqlScript+=wxT(" ALTER TABLE ")+column->GetQuotedFullTable()+
+				wxT(" ALTER COLUMN \"")+
+				GetColumnName()+wxT("\" DROP NOT NULL;");
+
+	if(column->GetNotNull())
+	{
+		sqlScript+=wxT(" ALTER TABLE ")+column->GetQuotedFullTable()+ 
+			wxT(" ALTER COLUMN \"")+
+			GetColumnName()+wxT("\" ")+wxT(" SET NOT NULL;\n ");
+	}
+	SetScript(sqlScript);
+}
+void AlterColumn::setTypes(wxString srcType,wxString destType)
+{
+	sourceDataType = srcType;
+	destinationDataType = destType;
+}
diff --git a/pgadmin/sv/svAlterFk.cpp b/pgadmin/sv/svAlterFk.cpp
new file mode 100644
index 0000000..1718b63
--- /dev/null
+++ b/pgadmin/sv/svAlterFk.cpp
@@ -0,0 +1,52 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterFk.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterFk.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgForeignKey.h"
+#include "sv/svAlterFk.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svFkDiff.h"
+
+AlterFk::AlterFk(DiffObject *obj)
+{
+	fk = ((FkDiff*)obj)->GetFk();
+	SetFkName(fk->GetName());
+	SetTableName(fk->GetTable()->GetName());
+	SetSchemaName(fk->GetSchema()->GetName());
+	SetMetaType(ALTERFK);
+}
+void AlterFk::GenerateScript()
+{
+	wxString sqlScript;
+	fk->ReadFkColumnInfo();
+
+	wxString qualifiedName;
+	if(GetSchemaName()!=wxT("public"))
+		qualifiedName = fk->GetSchema()->GetName()+wxT(".")+ GetTableName();
+	else
+		qualifiedName = GetTableName(); // by default , schema is public
+
+	if(alterCase==wxT("Add"))
+	{
+		sqlScript +=wxT(" ALTER TABLE \"")+qualifiedName+wxT("\" \n")+
+				wxT(" ADD CONSTRAINT \"")+ GetFkName() + wxT("\" FOREIGN KEY ")+ fk->GetDefinition();
+	}
+	else if(alterCase==wxT("Overwrite"))
+	{
+		sqlScript+=wxT(" ALTER TABLE \"")+qualifiedName+wxT("\" \n")+
+					wxT(" DROP CONSTRAINT \"")+GetFkName()+wxT("\"; \n ");
+
+		sqlScript +=wxT(" ALTER TABLE \"")+qualifiedName+wxT("\" \n")+
+				wxT(" ADD CONSTRAINT \"")+ GetFkName() + wxT("\" FOREIGN KEY ")+ fk->GetDefinition();
+	}
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svAlterIndex.cpp b/pgadmin/sv/svAlterIndex.cpp
new file mode 100644
index 0000000..7b3b3a9
--- /dev/null
+++ b/pgadmin/sv/svAlterIndex.cpp
@@ -0,0 +1,44 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterIndex.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterIndex.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgIndex.h"
+#include "sv/svAlterIndex.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svIndexDiff.h"
+
+AlterIndex::AlterIndex(DiffObject *obj)
+{
+	index = ((IndexDiff*)obj)->GetIndex();
+	SetIndexName(index->GetName());
+	SetTableName(index->GetTable()->GetName());
+	SetSchemaName(index->GetSchema()->GetName());
+	SetMetaType(ALTERINDEX);
+}
+void AlterIndex::GenerateScript()
+{
+	wxString sqlScript;
+	index->ReadIndexColumnInfo();
+	
+	if(alterCase==wxT("Add"))
+		sqlScript += index->GetCreate();
+	else if(alterCase==wxT("Overwrite"))
+	{
+		sqlScript+=wxT(" DROP INDEX ")+GetSchemaName()+wxT(".")+GetIndexName()+wxT(";\n");
+		sqlScript += index->GetCreate();
+	}
+
+	
+	
+	
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svAlterPk.cpp b/pgadmin/sv/svAlterPk.cpp
new file mode 100644
index 0000000..2ffc734
--- /dev/null
+++ b/pgadmin/sv/svAlterPk.cpp
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterPk.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterPk.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgPrimaryKey.h"
+#include "sv/svAlterPk.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svPkDiff.h"
+
+AlterPk::AlterPk(DiffObject *obj)
+{
+	pk = ((PkDiff*)obj)->GetPk();
+	SetPkName(pk->GetName());
+	SetTableName(pk->GetTable()->GetName());
+	SetSchemaName(pk->GetSchema()->GetName());
+	SetMetaType(ALTERPK);
+}
+void AlterPk::GenerateScript()
+{
+	wxString sqlScript;
+	pk->ReadPkColumnInfo();
+	
+	if(alterCase==wxT("Add"))
+	{
+		sqlScript+=wxT(" ALTER TABLE ")+GetSchemaName()+wxT(".")+GetTableName()+
+				wxT(" ADD CONSTRAINT \"")+GetPkName()+ wxT("\" PRIMARY KEY ") + pk->GetDefinition()+ wxT(";");
+	}
+	else if(alterCase==wxT("Overwrite"))
+	{
+		// testing here what kind of differences are there
+		sqlScript+=wxT(" ALTER TABLE ")+GetSchemaName()+wxT(".")+GetTableName()+
+				wxT(" DROP CONSTRAINT \"")+
+				GetPkName()+wxT("\";\n");
+		sqlScript+=wxT(" ALTER TABLE ")+GetSchemaName()+wxT(".")+GetTableName()+
+				wxT(" ADD CONSTRAINT \"")+GetPkName()+ wxT("\" PRIMARY KEY ") + pk->GetDefinition()+ wxT(";");
+	}
+	
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svAlterSchema.cpp b/pgadmin/sv/svAlterSchema.cpp
new file mode 100644
index 0000000..61b826e
--- /dev/null
+++ b/pgadmin/sv/svAlterSchema.cpp
@@ -0,0 +1,32 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterSchema.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterSchema.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgSchema.h"
+#include "sv/svAlterSchema.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svSchemaDiff.h"
+
+
+AlterSchema::AlterSchema(DiffObject *obj)
+{
+	schema = ((SchemaDiff*)obj)->GetSchema();
+	//schName = schemaName;
+	SetSchemaName(schema->GetName());
+	SetMetaType(ALTERSCHEMA);
+}
+
+void AlterSchema::GenerateScript()
+{
+	// no diff script expected for now
+	// here for standard code
+}
diff --git a/pgadmin/sv/svAlterTable.cpp b/pgadmin/sv/svAlterTable.cpp
new file mode 100644
index 0000000..8c0ea13
--- /dev/null
+++ b/pgadmin/sv/svAlterTable.cpp
@@ -0,0 +1,31 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterTable.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterTable.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgTable.h"
+#include "sv/svAlterTable.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svTableDiff.h"
+
+
+AlterTable::AlterTable(DiffObject *obj)
+{
+	table = ((TableDiff*)obj)->GetTable();
+	SetSchemaName(table->GetSchema()->GetName());
+	SetTableName(table->GetName());
+	SetMetaType(ALTERTABLE);
+}
+void AlterTable::GenerateScript()
+{
+	// no diff script expected for now
+	// here for standardardized code
+}
diff --git a/pgadmin/sv/svAlterUnique.cpp b/pgadmin/sv/svAlterUnique.cpp
new file mode 100644
index 0000000..bd4336a
--- /dev/null
+++ b/pgadmin/sv/svAlterUnique.cpp
@@ -0,0 +1,47 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svAlterUnique.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svAlterUnique.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgUnique.h"
+#include "sv/svAlterUnique.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svUniqueDiff.h"
+
+AlterUnique::AlterUnique(DiffObject *obj)
+{
+	unique = ((UniqueDiff*)obj)->GetUnique();
+	SetUniqueName(unique->GetName());
+	SetTableName(unique->GetTable()->GetName());
+	SetSchemaName(unique->GetSchema()->GetName());
+	SetMetaType(ALTERUNIQUE);
+}
+void AlterUnique::GenerateScript()
+{
+	wxString sqlScript;
+	unique->ReadUniqueColumnInfo();
+
+	if(alterCase==wxT("Add"))
+	{
+		sqlScript+=wxT(" ALTER TABLE \"")+GetSchemaName()+wxT(".")+GetTableName()+wxT("\"")+
+				wxT(" ADD CONSTRAINT \"")+GetUniqueName()+ wxT("\" UNIQUE ") + unique->GetDefinition()+ wxT(";");
+	}
+	else if(alterCase==wxT("Overwrite"))
+	{
+		// testing here what kind of differences are there
+		sqlScript+=wxT(" ALTER TABLE ")+GetSchemaName()+wxT(".")+GetTableName()+
+				wxT(" DROP CONSTRAINT \"")+
+				GetUniqueName()+wxT("\";\n");
+		sqlScript+=wxT(" ALTER TABLE ")+GetSchemaName()+wxT(".")+GetTableName()+
+				wxT(" ADD CONSTRAINT \"")+GetUniqueName()+ wxT("\" UNIQUE ") + unique->GetDefinition()+ wxT(";");
+	}
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svColumnDiff.cpp b/pgadmin/sv/svColumnDiff.cpp
new file mode 100644
index 0000000..6e7aef0
--- /dev/null
+++ b/pgadmin/sv/svColumnDiff.cpp
@@ -0,0 +1,348 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svColumnDiff.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svColumnDiff.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include"pgAdmin3.h"
+
+#include "sv/svColumnDiff.h"
+#include "sv/svDropColumn.h"
+#include "sv/svDropFk.h"
+#include "sv/svDropPk.h"
+#include "sv/svDropIndex.h"
+#include "sv/svDropUnique.h"
+#include "sv/svPkDiff.h"
+#include "sv/svUniqueDiff.h"
+#include "sv/svFkDiff.h"
+#include "sv/svIndexDiff.h"
+#include "sv/svAlterColumn.h"
+#include "sv/svDropView.h"
+
+
+bool ColumnDiff::GenStructuralDiff(DiffObject * trgColumn,ctlTree * src, ctlTree * trg,wxTreeItemId dummyId,ColumnScript *columnScr)
+{
+	ColumnDiff * trgCol = (ColumnDiff*)trgColumn;
+	pgColumn *pgc = trgCol->GetColumn();
+	wxString objname = pgc->GetName();
+	wxString tableName = pgc->GetTable()->GetName();
+	wxString schemaName = pgc->GetSchema()->GetName();
+	pgColumn * srcColumn = (pgColumn*)this->GetObject();
+
+	bool aS=srcColumn->GetNotNull();
+	bool aT=pgc->GetNotNull();
+
+	long bS=srcColumn->GetTyplen();
+	long bT=pgc->GetTyplen();
+	
+	bool cS=srcColumn->GetIsPK();
+	bool cT=pgc->GetIsPK();
+
+	long dS=srcColumn->GetTypmod();
+	
+	long dT=pgc->GetTypmod();
+
+	long eS=srcColumn->GetLength();
+	long eT=pgc->GetLength();
+
+	bool gS=srcColumn->GetIsFK();
+	bool gT=pgc->GetIsFK();
+
+	wxString fS=srcColumn->GetVarTypename();
+	wxString fT=pgc->GetVarTypename();
+
+	// finding difference
+	if(srcColumn->GetNotNull()!= pgc->GetNotNull() ||
+		srcColumn->GetTyplen()!= pgc->GetTyplen() || 
+		srcColumn->GetIsPK()!= pgc->GetIsPK()		||
+		srcColumn->GetIsFK()!= pgc->GetIsFK() || 
+		srcColumn->GetTypmod()!= pgc->GetTypmod() ||
+		srcColumn->GetLength()!= pgc->GetLength() ||
+		srcColumn->GetVarTypename()!= pgc->GetVarTypename())
+	{
+		// showing present elements @ target
+		////////////////////////////////////
+		trg->SetItemImage(pgc->GetId(),svImages.IMG_COLUMN_CHG);
+		wxTreeItemId id = trg->GetItemParent(pgc->GetId());
+		trg->SetItemImage(id,svImages.IMG_COLUMNS_CHG);
+		/////////////////////////////////////
+		ColumnElement * alterColumn = new AlterColumn(this);
+
+		if(!srcColumn->GetNotNull() && pgc->GetNotNull())
+			((AlterColumn*)alterColumn)->setDropNotNull(true); // drop the target not null
+	
+		if(srcColumn->GetVarTypename()!=pgc->GetVarTypename())
+		{
+			((AlterColumn*)alterColumn)->setTypChange(true); // change the type also
+			((AlterColumn*)alterColumn)->setTypes(pgc->GetVarTypename(),srcColumn->GetVarTypename()); 
+		}
+
+		((AlterColumn*)alterColumn)->GenerateScript();
+		columnScr->AddDiffElement(alterColumn);
+
+		return true;
+	}
+	return false;
+}
+/////////////////////////////////////////////////////////
+void ColumnScript::GenerateScript()
+{
+
+}
+wxString ColumnScript::GenerateCreateScript(wxString tableName,wxString schemaName)
+{
+	wxString createColumnScripts,tmp;
+	for(size_t i=0; i<this->columnDiffList.GetCount();i++)
+	{
+		ColumnElement *colElem = this->columnDiffList.Item(i);
+		if(colElem->GetMetaType() == CRTCOLUMN && 
+			colElem->GetTableName() == tableName &&
+			colElem->GetSchemaName() == schemaName)
+		{
+			tmp=colElem->GetScript();
+			if(tmp.length() > 0)
+			{
+				createColumnScripts+=tmp;
+				createColumnScripts+=wxT(",");
+				createColumnScripts+=wxT("\n");
+			}
+			
+		}
+	}
+	createColumnScripts.RemoveLast();
+	createColumnScripts.RemoveLast();
+	if(createColumnScripts.length()>0)
+		createColumnScripts+=wxT("\n");
+	
+	return createColumnScripts;
+}
+// this function needs handle of list to manage the dependents
+wxString ColumnScript::GenerateAlterScript(wxString tableName,wxString schemaName,
+							PkScript *pkScr,FkScript *fkScr,IndexScript* indScr,UniqueScript *uniScr,ViewScript *viewScr,wxString ObjType)
+{
+	int SearchMetaType;
+	if(ObjType == wxT("DROP")) // fetch only drop elements
+		SearchMetaType = DROPCOLUMN;
+	else
+		SearchMetaType = ADDCOLUMN; 
+
+	wxString alterColumnScripts,tmp;
+	for(size_t i=0; i<this->columnDiffList.GetCount();i++)
+	{
+		ColumnElement *colElem = this->columnDiffList.Item(i);
+		wxString name = colElem->GetTableName();
+		wxString name1= colElem->GetSchemaName();
+		wxString colName = colElem->GetColumnName();
+		int mt=colElem->GetMetaType();
+		
+		if((colElem->GetMetaType() == SearchMetaType || colElem->GetMetaType() == ALTERCOLUMN) &&
+			colElem->GetTableName() == tableName &&
+			colElem->GetSchemaName() == schemaName)
+		{
+			// go through with all the dependencies first
+			if(colElem->GetMetaType()==DROPCOLUMN) 
+			{
+				DropColumn *dropCol = (DropColumn*)colElem;
+				if(dropCol->HasFkDep()) // col has fk dependent
+				{
+					for(size_t i=0; i< dropCol->GetDependentFkList().GetCount(); i++)
+					{
+						int fkId = dropCol->GetDependentFkList().Item(i);
+						// fetch the foriegn key from list
+						FkElement * fk = fkScr->GetFkList().Item(fkId);
+						if(!((DropFk*)fk)->IsAlreadyApplied())
+						{
+							tmp = ((DropFk*)fk)->GetScript(); // generating the drop script
+							if(tmp.length()>0)
+							alterColumnScripts+=tmp;
+						
+						}
+					}
+				}
+				if(dropCol->HasPkDep()) // col has pk dependent
+				{
+					int pkId = dropCol->GetColDepPkId();
+					PkElement * pk = pkScr->GetPkList().Item(pkId);
+					if(!((DropPk*)pk)->IsAlreadyApplied())
+					{
+						tmp = ((DropPk*)pk)->GetScript(); // generating the drop script
+						if(tmp.length()>0)
+							alterColumnScripts+=tmp;
+					}
+				}
+				if(dropCol->HasUniqueDep()) // col has unique
+				{
+					int uniqueId = dropCol->GetColDepUniqueId();
+					UniqueElement * unique = uniScr->GetUniqueList().Item(uniqueId);
+
+					if(!((DropUnique*)unique)->IsAlreadyApplied())
+					{
+						tmp = ((DropUnique*)unique)->GetScript(); // generating the drop script
+						if(tmp.length()>0)
+							alterColumnScripts+=tmp;
+					}
+				}
+				if(dropCol->HasIndexDep()) // col has index dependent
+				{
+					for(size_t i=0; i< dropCol->GetDependentIndexList().GetCount(); i++)
+					{
+						int indexId = dropCol->GetDependentIndexList().Item(i);
+						IndexElement * index = indScr->GetIndexList().Item(indexId);
+						
+						// fetch the foriegn key from list
+						if(!((DropIndex*)index)->IsAlreadyApplied())
+						{
+							tmp = ((DropIndex*)index)->GetScript(); // generating the drop script
+							if(tmp.length()>0)
+								alterColumnScripts+=tmp;
+						}
+					}
+				}
+				if(dropCol->HasViewDep())
+				{
+					for(size_t i=0; i< dropCol->GetDependentViewList().GetCount(); i++)
+					{
+						int indexId = dropCol->GetDependentViewList().Item(i);
+						ViewElement * view = viewScr->GetViewList().Item(indexId);
+						
+						// fetch the foriegn key from list
+						if(!((DropView*)view)->IsAlreadyApplied())
+						{
+							tmp = ((DropView*)view)->GetScript(); // generating the drop script
+							if(tmp.length()>0)
+								alterColumnScripts+=tmp;
+						}
+					}
+				}
+				// every dependency catered , now just add my scripts
+				tmp=colElem->GetScript();  
+				if(tmp.length()>0)
+					alterColumnScripts+=tmp;
+			}
+			else if(colElem->GetMetaType()==ADDCOLUMN)
+			{
+				tmp=colElem->GetScript();  
+				if(tmp.length()>0)
+					alterColumnScripts+=tmp;
+			}
+			else if (colElem->GetMetaType()==ALTERCOLUMN)
+			{
+				tmp=colElem->GetScript();  
+				if(tmp.length()>0)
+					alterColumnScripts+=tmp;
+			}
+		}
+	}
+	return alterColumnScripts;
+}
+// this function needs handle of list to manage the dependents
+wxString ColumnScript::GenerateDropScript(wxString tableName,wxString schemaName,
+										PkScript *pkScr,FkScript *fkScr,IndexScript* indScr,UniqueScript *uniScr,ViewScript* viewScr)
+{
+	wxString dropColumnScripts,tmp;
+	for(size_t i=0; i<this->columnDiffList.GetCount();i++)
+	{
+		ColumnElement *colElem = this->columnDiffList.Item(i);
+		wxString name = colElem->GetTableName();
+		wxString name1= colElem->GetSchemaName();
+		wxString colName = colElem->GetColumnName();
+		int mt=colElem->GetMetaType();
+		if(colElem->GetMetaType() == DROPCOLUMN && 
+			colElem->GetTableName() == tableName &&
+			colElem->GetSchemaName() == schemaName)
+		{
+			// go through with all the dependencies first
+			
+			DropColumn *dropCol = (DropColumn*)colElem;
+			if(dropCol->HasFkDep()) // col has fk dependent
+			{
+				for(size_t i=0; i< dropCol->GetDependentFkList().GetCount(); i++)
+				{
+					int fkId = dropCol->GetDependentFkList().Item(i);
+					// fetch the foriegn key from list
+					FkElement * fk = fkScr->GetFkList().Item(fkId);
+					if(!((DropFk*)fk)->IsAlreadyApplied())
+					{
+						tmp = ((DropFk*)fk)->GetScript(); // generating the drop script
+						if(tmp.length()>0)
+						dropColumnScripts+=tmp;
+					
+					}
+				}
+			}
+			if(dropCol->HasPkDep()) // col has pk dependent
+			{
+				int pkId = dropCol->GetColDepPkId();
+				PkElement * pk = pkScr->GetPkList().Item(pkId);
+				if(!((DropPk*)pk)->IsAlreadyApplied())
+				{
+					tmp = ((DropPk*)pk)->GetScript(); // generating the drop script
+					if(tmp.length()>0)
+						dropColumnScripts+=tmp;
+				}
+			}
+			if(dropCol->HasUniqueDep()) // col has unique
+			{
+				int uniqueId = dropCol->GetColDepUniqueId();
+				UniqueElement * unique = uniScr->GetUniqueList().Item(uniqueId);
+
+				if(!((DropUnique*)unique)->IsAlreadyApplied())
+				{
+					tmp = ((DropUnique*)unique)->GetScript(); // generating the drop script
+					if(tmp.length()>0)
+						dropColumnScripts+=tmp;
+				}
+			}
+			if(dropCol->HasIndexDep()) // col has index dependent
+			{
+				for(size_t i=0; i< dropCol->GetDependentIndexList().GetCount(); i++)
+				{
+					int indexId = dropCol->GetDependentIndexList().Item(i);
+					IndexElement * index = indScr->GetIndexList().Item(indexId);
+					
+					// fetch the foriegn key from list
+					if(!((DropIndex*)index)->IsAlreadyApplied())
+					{
+						tmp = ((DropIndex*)index)->GetScript(); // generating the drop script
+						if(tmp.length()>0)
+						dropColumnScripts+=tmp;
+					}
+				}
+			}
+			if(dropCol->HasViewDep())
+			{
+				for(size_t i=0; i< dropCol->GetDependentViewList().GetCount(); i++)
+				{
+					int indexId = dropCol->GetDependentViewList().Item(i);
+					ViewElement * view = viewScr->GetViewList().Item(indexId);
+					
+					// fetch the foriegn key from list
+					if(!((DropView*)view)->IsAlreadyApplied())
+					{
+						tmp = ((DropView*)view)->GetScript(); // generating the drop script
+						if(tmp.length()>0)
+							dropColumnScripts+=tmp;
+					}
+				}
+			}
+			// every dependency catered , now just add my scripts
+			tmp=colElem->GetScript();  
+			if(tmp.length()>0)
+				dropColumnScripts+=tmp;
+		}
+	}
+	return dropColumnScripts;
+}
+
+void ColumnScript::ApplyScript()
+{}
+void ColumnScript::AddDiffElement(ColumnElement * de)
+{
+	this->columnDiffList.Add(de);
+}
+
diff --git a/pgadmin/sv/svCreateColumn.cpp b/pgadmin/sv/svCreateColumn.cpp
new file mode 100644
index 0000000..375f9d0
--- /dev/null
+++ b/pgadmin/sv/svCreateColumn.cpp
@@ -0,0 +1,35 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateColumn.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateColumn.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgColumn.h"
+#include "sv/svCreateColumn.h"
+#include "sv/svColumnDiff.h"
+#include "sv/svDiffSystem.h"
+
+CreateColumn::CreateColumn(DiffObject * obj)
+{
+	column = ((ColumnDiff *)obj)->GetColumn();
+	SetColumnName(column->GetName());
+	SetTableName(column->GetTable()->GetName());
+	SetSchemaName(column->GetSchema()->GetName());
+	SetMetaType(CRTCOLUMN);
+}
+void CreateColumn::GenerateScript()
+{
+	wxString sqlScript;
+	sqlScript += GetColumnName() +wxT(" ") + 
+						column->GetQuotedTypename();
+	if(column->GetNotNull())
+		sqlScript+=wxT(" NOT NULL ");
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svCreateFk.cpp b/pgadmin/sv/svCreateFk.cpp
new file mode 100644
index 0000000..2fd4d66
--- /dev/null
+++ b/pgadmin/sv/svCreateFk.cpp
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateFk.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateFk.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgForeignKey.h"
+#include "sv/svCreateFk.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svFkDiff.h"
+
+CreateFk::CreateFk(DiffObject * obj)
+{
+	fk = ((FkDiff *)obj)->GetFk();
+	SetFkName(fk->GetName());
+	SetTableName(fk->GetTable()->GetName());
+	SetSchemaName(fk->GetSchema()->GetName());
+	
+	SetMetaType(CRTFK);
+}
+void CreateFk::GenerateScript()
+{
+	wxString sqlScript;
+	fk->ReadFkColumnInfo();
+	wxString qualifiedName;
+	if(GetSchemaName()!=wxT("public"))
+		qualifiedName = fk->GetSchema()->GetName()+wxT(".")+ GetTableName();
+	else
+		qualifiedName = GetTableName(); // by default , schema is public
+
+	sqlScript = wxT(" ALTER TABLE \"")+qualifiedName+wxT("\" \n")
+		wxT(" ADD CONSTRAINT \"")+ GetFkName() + wxT("\" FOREIGN KEY ")+ fk->GetDefinition();
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svCreateIndex.cpp b/pgadmin/sv/svCreateIndex.cpp
new file mode 100644
index 0000000..a9a6aa2
--- /dev/null
+++ b/pgadmin/sv/svCreateIndex.cpp
@@ -0,0 +1,36 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateIndex.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateIndex.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgIndex.h"
+#include "sv/svCreateIndex.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svIndexDiff.h"
+
+CreateIndex::CreateIndex(DiffObject * obj)
+{
+	index = ((IndexDiff *)obj)->GetIndex();;
+	SetIndexName(index->GetName());
+	SetTableName(index->GetTable()->GetName());
+	SetSchemaName(index->GetSchema()->GetName());
+	SetMetaType(CRTINDEX);
+}
+void CreateIndex::GenerateScript()
+{
+	wxString sqlScript;
+	index->ReadIndexColumnInfo();
+	sqlScript += index->GetCreate();
+	SetScript(sqlScript);
+}
+void CreateIndex::ApplyScript()
+{
+}
diff --git a/pgadmin/sv/svCreatePk.cpp b/pgadmin/sv/svCreatePk.cpp
new file mode 100644
index 0000000..0a7a589
--- /dev/null
+++ b/pgadmin/sv/svCreatePk.cpp
@@ -0,0 +1,36 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreatePk.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreatePk.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgPrimaryKey.h"
+#include "sv/svCreatePk.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svPkDiff.h"
+
+CreatePk::CreatePk(DiffObject * obj)
+{
+	pk = ((PkDiff *)obj)->GetPk();;
+	SetPkName(pk->GetName());
+	SetTableName(pk->GetTable()->GetName());
+	SetSchemaName(pk->GetSchema()->GetName());
+	SetMetaType(CRTPK);
+}
+void CreatePk::GenerateScript()
+{
+	wxString sqlScript;
+	pk->ReadPkColumnInfo();
+	sqlScript = wxT("CONSTRAINT \"")+ GetPkName()+ wxT("\" PRIMARY KEY")+ pk->GetDefinition();
+	SetScript(sqlScript);
+}
+void CreatePk::ApplyScript()
+{
+}
diff --git a/pgadmin/sv/svCreateRule.cpp b/pgadmin/sv/svCreateRule.cpp
new file mode 100644
index 0000000..c552276
--- /dev/null
+++ b/pgadmin/sv/svCreateRule.cpp
@@ -0,0 +1,33 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateRule.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateRule.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgRule.h"
+#include "sv/svCreateRule.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svRuleDiff.h"
+
+CreateRule::CreateRule(DiffObject * obj)
+{
+	rule = ((RuleDiff *)obj)->GetRule();;
+	SetRuleName(rule->GetName());
+	SetViewName(rule->GetTable()->GetName());
+	SetSchemaName(rule->GetSchema()->GetName());
+	SetMetaType(CRTRULE);
+}
+void CreateRule::GenerateScript()
+{
+	wxString sqlScript;
+	//rule->ReadPkColumnInfo();
+	//sqlScript = wxT("CONSTRAINT \"")+ GetPkName()+ wxT("\" PRIMARY KEY")+ pk->GetDefinition();
+	//SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svCreateSchema.cpp b/pgadmin/sv/svCreateSchema.cpp
new file mode 100644
index 0000000..30dc4ec
--- /dev/null
+++ b/pgadmin/sv/svCreateSchema.cpp
@@ -0,0 +1,36 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateSchema.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateSchema.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgSchema.h"
+#include "sv/svCreateSchema.h"
+#include "sv/svDiffSystem.h"
+
+
+CreateSchema::CreateSchema(DiffObject * obj)
+{
+	sch = ((SchemaDiff *)obj)->GetSchema();
+	SetSchemaName(sch->GetName());
+	SetMetaType(CRTSCHEMA);
+}
+
+void CreateSchema::GenerateScript()
+{
+	wxString sqlScript;
+	sqlScript = wxT("CREATE SCHEMA ")+
+			GetSchemaName()+
+			wxT(";");
+	SetScript(sqlScript);
+}
+void CreateSchema::ApplyScript()
+{
+}
diff --git a/pgadmin/sv/svCreateTable.cpp b/pgadmin/sv/svCreateTable.cpp
new file mode 100644
index 0000000..814447a
--- /dev/null
+++ b/pgadmin/sv/svCreateTable.cpp
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateTable.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateTable.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgTable.h"
+#include "sv/svCreateTable.h"
+#include "sv/svDiffSystem.h"
+
+
+CreateTable::CreateTable(DiffObject * obj)
+{
+	table = ((TableDiff *)obj)->GetTable();
+	SetSchemaName(table->GetSchema()->GetName());
+	wxString abc=table->GetSchema()->GetName();
+	SetTableName(table->GetName());
+	wxString name1 = table->GetSchema()->GetName();
+	wxString name2 = table->GetName();
+	
+	SetMetaType(CRTTABLE);
+}
+void CreateTable::GenerateScript()
+{
+	wxString sqlScript;
+
+	wxString qualifiedName;
+	wxString w = GetSchemaName();
+	if(GetSchemaName()!=wxT("public"))
+		qualifiedName = wxT("\"")+GetSchemaName()+wxT("\".\"")+ GetTableName()+wxT("\"");
+	else
+		qualifiedName = wxT("\"")+GetTableName()+wxT("\""); // by default , schema is public
+	
+	sqlScript = wxT("CREATE TABLE ")+
+			qualifiedName+wxT("\n");
+	SetScript(sqlScript);
+
+}
+void CreateTable::ApplyScript()
+{
+}
diff --git a/pgadmin/sv/svCreateUnique.cpp b/pgadmin/sv/svCreateUnique.cpp
new file mode 100644
index 0000000..a6e1786
--- /dev/null
+++ b/pgadmin/sv/svCreateUnique.cpp
@@ -0,0 +1,34 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateUnique.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateUnique.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgUnique.h"
+#include "sv/svCreateUnique.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svUniqueDiff.h"
+
+CreateUnique::CreateUnique(DiffObject * obj)
+{
+	unique = ((UniqueDiff *)obj)->GetUnique();;
+	SetUniqueName(unique->GetName());
+	SetTableName(unique->GetTable()->GetName());
+	SetSchemaName(unique->GetSchema()->GetName());
+	SetMetaType(CRTUNIQUE);
+}
+void CreateUnique::GenerateScript()
+{
+	wxString sqlScript;
+	unique->ReadUniqueColumnInfo();
+	sqlScript+=wxT(" CONSTRAINT \"")+ GetUniqueName()+ wxT("\" UNIQUE ") + unique->GetDefinition();
+	SetScript(sqlScript);
+
+}
diff --git a/pgadmin/sv/svCreateView.cpp b/pgadmin/sv/svCreateView.cpp
new file mode 100644
index 0000000..1564f14
--- /dev/null
+++ b/pgadmin/sv/svCreateView.cpp
@@ -0,0 +1,35 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svCreateView.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svCreateView.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgView.h"
+#include "sv/svCreateView.h"
+#include "sv/svDiffSystem.h"
+
+
+CreateView::CreateView(DiffObject * obj)
+{
+	view = ((ViewDiff *)obj)->GetView();
+	SetSchemaName(view->GetSchema()->GetName());
+	
+	SetViewName(view->GetName());
+	SetMetaType(CRTVIEW);
+}
+void CreateView::GenerateScript()
+{
+	wxString sqlScript;
+	sqlScript+=wxT("\n\nCREATE OR REPLACE VIEW ") + view->GetQuotedFullIdentifier() + wxT(" AS \n")
+            + view->GetFormattedDefinition()
+            + wxT("\n\n") 
+            + view->GetOwnerSql(7, 3, wxT("TABLE ") + view->GetQuotedFullIdentifier());
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svDbDiff.cpp b/pgadmin/sv/svDbDiff.cpp
new file mode 100644
index 0000000..12f32fa
--- /dev/null
+++ b/pgadmin/sv/svDbDiff.cpp
@@ -0,0 +1,298 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDbDiff.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDbDiff.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include"pgAdmin3.h"
+
+#include "sv/svSchemaDiff.h"
+#include "sv/svCreateSchema.h"
+#include "sv/svAlterSchema.h"
+#include "sv/svDropSchema.h"
+#include "sv/svDbDiff.h"
+#include "sv/svDiffSystem.h"
+
+DbDiff::DbDiff(pgDatabase * db):DiffObject(db)
+{
+	dbhandle = (pgDatabase*)db;	
+}
+
+// loading the whole structure
+void DbDiff::LoadDiffSystemObjects(wxTreeItemId db, ctlTree * tree)
+{
+	wxTreeItemId schemaRoot,schemaList;
+	wxCookieType dbCookie,schListCookie;
+
+
+	if(tree->HasChildren(db))
+	{
+		schemaRoot = tree->GetFirstChild(db,dbCookie);
+		schemaList = tree->GetFirstChild(schemaRoot,schListCookie);
+		while(schemaList)
+		{
+			pgObject * schema = tree->GetObject(schemaList);
+			wxString name = schema->GetName();
+			SchemaDiff * dschema = new SchemaDiff(schema);
+			this->objlist.Add(dschema); // adding schema to the db
+			dschema->LoadDiffSystemObjects(schema->GetId(),tree);
+			schemaList = tree->GetNextChild(schemaRoot,schListCookie);
+		}
+	}
+}
+void DbDiff::GenStructuralDiff(DiffObject * trgDb, ctlTree *src, ctlTree *trg, wxTreeItemId dummyId,DbScript * dbScr)
+{
+	DbDiff * trgDatabase = (DbDiff *)trgDb;
+	bool schHaveChanges;
+
+	// searching for the schema objects not present in trg
+	for(size_t i=0; i < (this->objlist.GetCount()) ; i++)
+	{
+		wxString SrcSchemaName;
+		SchemaDiff * srcSchema = (SchemaDiff *)(this->objlist.Item(i)); // getting schema 
+		SrcSchemaName  = srcSchema->GetSchema()->GetName();
+		 
+		if(!trgDatabase->IsPresent(SrcSchemaName)) // if missing in target
+		{ 
+			pgSchema* pgs = srcSchema->GetSchema();
+			
+			SchemaElement* createSchema = new CreateSchema(srcSchema); 
+			((CreateSchema*)createSchema)->GenerateScript(); // this would generate the script for schema difference
+		    dbScr->AddDiffElement(createSchema);
+			
+			//////////////////////////////////////////////////////////////////////////////////////////////
+			// performing UI changes, 
+			
+			// showing elements to be added at target end
+			
+			wxCookieType cookie;
+			wxTreeItemId schemasId = NULL;
+			wxTreeItemId schemaId = NULL;
+
+			wxTreeItemId dbId = trgDatabase->GetObject()->GetId();
+			schemasId = trg->GetFirstChild(dbId,cookie);
+			schemaId = trg->AppendItem(schemasId,SrcSchemaName,svImages.IMG_SCH_PRES,-1,NULL);
+			trg->SetItemImage(schemasId,svImages.IMG_SCHEMAS_CHG);  
+			trg->SortChildren(schemasId);
+
+			// schema is not present on the target pass dummy object id
+			srcSchema->GenStructuralDiff(NULL,src,trg,schemaId,dbScr->GetSchemaScriptHandle());
+			
+			////////////////////////////////////////////////////////////////////////////////////////////
+		}
+		else // schemas got matched
+		{ 
+			// this just registers a schema for an alter element down the road
+			SchemaElement* alterSchema = new AlterSchema(srcSchema); 
+			((AlterSchema*)alterSchema)->GenerateScript(); 
+		    dbScr->AddDiffElement(alterSchema);
+
+			// for tables
+			SchemaDiff * trgSch;
+			trgSch = trgDatabase->FindObj(SrcSchemaName);
+			srcSchema->SetDiffType(PGM_TABLE);
+			
+			bool schChangesExist=false;
+			schHaveChanges = srcSchema->GenStructuralDiff(trgSch,src,trg,NULL,dbScr->GetSchemaScriptHandle());
+
+			wxTreeItemId schemasId;
+			wxCookieType cookie;
+			if(schChangesExist)
+			{
+				// changing schemas collection icon
+				wxTreeItemId dbId = trgDatabase->GetObject()->GetId();
+				schemasId = trg->GetFirstChild(dbId,cookie);
+				trg->SetItemImage(schemasId,svImages.IMG_SCHEMAS_CHG);  
+			
+				// changing schema icon
+				wxTreeItemId schId = trgSch->GetObject()->GetId();
+				trg->SetItemImage(schId,svImages.IMG_SCH_CHG); 
+			}
+						
+			// for views
+			trgSch = trgDatabase->FindObj(SrcSchemaName);
+			srcSchema->SetDiffType(PGM_VIEW);
+			schChangesExist = srcSchema->GenStructuralDiff(trgSch,src,trg,NULL,dbScr->GetSchemaScriptHandle());
+			if(schChangesExist)
+			{
+				// changing schemas collection icon
+				wxTreeItemId dbId = trgDatabase->GetObject()->GetId();
+				schemasId = trg->GetFirstChild(dbId,cookie);
+				trg->SetItemImage(schemasId,svImages.IMG_SCHEMAS_CHG);  
+			
+				// changing schema icon
+				wxTreeItemId schId = trgSch->GetObject()->GetId();
+				trg->SetItemImage(schId,svImages.IMG_SCH_CHG);
+			}
+		}
+	}
+	// searching for the schema objects not present in source
+	for(size_t i=0; i < (trgDatabase->GetSchemaList().GetCount()) ; i++)
+	{
+		wxString trgSchemaName;
+		SchemaDiff * trgSchema = (SchemaDiff *)(trgDatabase->GetSchemaList().Item(i)); // getting schema 
+		trgSchemaName  = trgSchema->GetSchema()->GetName();
+		 
+		if(!this->IsPresent(trgSchemaName)) 
+		{ 
+			pgSchema* pgs = trgSchema->GetSchema();
+			DiffElement* dropSchema = new DropSchema(trgSchema); 
+			((DropSchema*)dropSchema)->GenerateScript(); // this would generate the script for schema difference
+			dbScr->AddDiffElement(dropSchema);
+			
+			// performing UI changes
+			// showing elements to be dropped @ destination
+			wxTreeItemId dbId = trgDatabase->GetObject()->GetId();
+			wxCookieType cookie;
+			wxTreeItemId schemasId=trg->GetFirstChild(dbId,cookie);
+			trg->SetItemImage(trgSchema->GetObject()->GetId(),svImages.IMG_SCH_MISS);
+			trg->SetItemImage(schemasId,svImages.IMG_SCHEMAS_CHG);  
+			trg->SortChildren(trg->GetItemParent(schemasId));
+
+			SchemaDiff::DropSchemaObject(trgSchema,src,trg,dbScr->GetSchemaScriptHandle());
+		}
+	}
+	// assuming that the target schemas has items , must check here
+	if(!(trgDatabase->GetSchemaList().empty()))
+	{
+		SchemaDiff *pgS = (SchemaDiff *)(trgDatabase->GetSchemaList()).Item(0);  
+		trg->Expand(trg->GetItemParent(pgS->GetSchema()->GetId()));
+	}
+}
+
+bool DbDiff::IsPresent(wxString objname)
+{
+	bool found = false;
+	for(size_t i =0 ; i< (this->objlist.GetCount()) ; i++)
+	{
+		SchemaDiff * schdiff = (SchemaDiff*)(this->objlist.Item(i));
+		pgSchema *pgS = schdiff->GetSchema();
+		
+		if(pgS->GetName() == objname) 
+		{ 
+			found = true;
+			break;
+		}
+	}
+	if(found)
+		return true;
+	else
+		return false;
+}
+SchemaDiff *DbDiff::FindObj(wxString objname)
+{
+	bool found = false;
+	SchemaDiff * schdiff;
+	for(size_t i =0 ; i< (this->objlist.GetCount()) ; i++)
+	{
+		schdiff = (SchemaDiff*)(this->objlist.Item(i));
+		pgSchema *pgS = schdiff->GetSchema();
+		
+		if(pgS->GetName() == objname) 
+		{ 
+			found = true;
+			break;
+		}
+	}
+	if(found)
+		return schdiff;
+	else
+		return 0;
+} 
+
+
+void DbScript::Initialize()
+{
+	schemaScript = new SchemaScript();
+	schemaScript->Initialize();
+}
+void DbScript::GenerateScript()
+{
+
+}
+wxString DbScript::GenerateCreateScript()
+{
+	wxString createScript,tmp;
+	for(size_t i=0; i<this->DiffList.GetCount(); i++)
+	{
+		SchemaElement *schElement = (SchemaElement *)this->DiffList.Item(i);
+		wxString name = schElement->GetSchemaName();
+		if(schElement->GetMetaType()==CRTSCHEMA)
+		{
+			tmp=schElement->GetScript();
+			if(tmp.length()>0)
+			{
+				createScript+=tmp;
+				createScript+=wxT("\n");
+			}
+			createScript+=schemaScript->GenerateCreateScript(schElement->GetSchemaName());
+		}
+	}
+	return createScript; 
+}
+
+wxString DbScript::GenerateAlterScript()
+{
+	wxString alterScript;
+	for(size_t i=0; i<this->DiffList.GetCount(); i++)
+	{
+		SchemaElement *schElement = (SchemaElement *)this->DiffList.Item(i);
+		if(schElement->GetMetaType()==ALTERSCHEMA)
+		{
+			// finding diff of lower level objects
+			alterScript+=schemaScript->GenerateAlterScript(schElement->GetSchemaName());
+		}
+	}
+	return alterScript; 
+
+}
+wxString DbScript::GenerateFkScripts()
+{
+	wxString fkScript;
+	for(size_t i=0; i<this->DiffList.GetCount(); i++)
+	{
+		SchemaElement *schElement = (SchemaElement *)this->DiffList.Item(i);
+		if(schElement->GetMetaType()==ALTERSCHEMA || schElement->GetMetaType()==CRTSCHEMA)
+		{
+			// finding diff of lower level objects
+			fkScript+=schemaScript->GenerateFkScripts(schElement->GetSchemaName());
+		}
+	}
+	return fkScript; 
+}
+wxString DbScript::GenerateDropScript()
+{
+	wxString dropScript,tmp;
+	for(size_t i=0; i<this->DiffList.GetCount(); i++)
+	{
+		SchemaElement *schElement = (SchemaElement *)this->DiffList.Item(i);
+		if(schElement->GetMetaType()==DROPSCHEMA)
+		{
+			// finding diff of lower level objects
+			dropScript+=schemaScript->GenerateDropScript(schElement->GetSchemaName());
+			
+			if(!schElement->IsAlreadyApplied())
+			{
+				tmp=schElement->GetScript();
+				if(tmp.length()>0)
+				{
+					dropScript+=tmp;
+					dropScript+=wxT("\n");
+				}
+			}
+		}
+	}
+	return dropScript; 
+}
+
+void DbScript::ApplyScript()
+{}
+void DbScript::AddDiffElement(DiffElement * de)
+{
+	this->DiffList.Add(de);
+}
diff --git a/pgadmin/sv/svDiffElement.cpp b/pgadmin/sv/svDiffElement.cpp
new file mode 100644
index 0000000..112c78a
--- /dev/null
+++ b/pgadmin/sv/svDiffElement.cpp
@@ -0,0 +1,16 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDiffElement.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDiffElement.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include"pgAdmin3.h"
+
+#include "sv/svDiffElement.h"
+
+
diff --git a/pgadmin/sv/svDiffObject.cpp b/pgadmin/sv/svDiffObject.cpp
new file mode 100644
index 0000000..122a172
--- /dev/null
+++ b/pgadmin/sv/svDiffObject.cpp
@@ -0,0 +1,216 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDiffObject.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDiffObject.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include"pgAdmin3.h"
+
+#include "sv/svDiffObject.h"
+#include "sv/svDiffSystem.h"
+
+// this would provide with dependends of 
+// pk,unique,fk or else
+void DiffObject::FetchDep(pgObject * obj,const wxString query, const wxString &clsorder,DependentObjArray &depList)
+{
+	pgDatabase *db = obj->GetDatabase();
+	pgConn *conn = obj->GetConnection();
+	wxString name = obj->GetName();
+
+    if (conn)
+    {
+        pgSet *set;
+ 
+        set=conn->ExecuteSet(query + wxT("\n")
+            wxT("   AND ") + clsorder + wxT(" IN (\n")
+            wxT("   SELECT oid FROM pg_class\n")
+            wxT("    WHERE relname IN ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc',\n")
+            wxT("                      'pg_rewrite', 'pg_namespace', 'pg_trigger', 'pg_type', 'pg_attrdef'))\n")
+            wxT(" ORDER BY ") + clsorder + wxT(", cl.relkind"));
+
+        if (set)
+        {
+            while (!set->Eof())
+            {
+                wxString refname;
+				wxString _refname;
+                //wxString _refname = set->GetVal(wxT("refname"));
+				DependencyObj *d = new DependencyObj();
+				 d->objName = set->GetVal(wxT("refname"));
+
+				 if (db)
+				 {
+                    //d->schemaName = db->GetQuotedSchemaPrefix(set->GetVal(wxT("nspname")));
+					 d->schemaName = set->GetVal(wxT("nspname"));
+				 }
+                else
+                {
+                    refname = qtIdent(set->GetVal(wxT("nspname")));
+                    /*if (!refname.IsEmpty())
+                        refname += wxT(".");*/
+                }
+
+                wxString typestr=set->GetVal(wxT("type"));
+                pgaFactory *depFactory=0;
+                switch (typestr.c_str()[0])
+                {
+                    case 'c':
+                    case 's':   // we don't know these; internally handled
+                    case 't':   set->MoveNext(); continue;
+
+                    case 'r':
+                    {
+                        if (StrToLong(typestr.Mid(1)) > 0)
+                            depFactory = &columnFactory;
+                        else
+                            depFactory=&tableFactory;
+                        break;
+                    }
+                    case 'i':   depFactory=&indexFactory;    break;
+                    case 'S':   depFactory=&sequenceFactory; break;
+                    case 'v':   depFactory=&viewFactory;     break;
+                    case 'x':   depFactory=&extTableFactory; break;
+                    case 'p':   depFactory=&functionFactory; break;
+                    case 'n':   depFactory=&schemaFactory;   break;
+                    case 'y':   depFactory=&typeFactory;     break;
+                    case 'T':   depFactory=&triggerFactory;  break;
+                    case 'l':   depFactory=&languageFactory; break;
+                    case 'R':
+                    {
+                        refname = _refname + wxT(" ON ") + refname + set->GetVal(wxT("ownertable"));
+						d->tableName = set->GetVal(wxT("ownertable"));
+						_refname=wxEmptyString;
+                        depFactory=&ruleFactory;
+                        break;
+                    }
+                    case 'C':
+                    {
+                        switch (typestr.c_str()[1])
+                        {
+                            case 'c':   depFactory=&checkFactory;        break;
+                            case 'f':   
+                                //refname += set->GetVal(wxT("ownertable")) + wxT(".");
+								d->tableName = set->GetVal(wxT("ownertable"));
+                                depFactory=&foreignKeyFactory;   break;
+                            case 'p':   depFactory=&primaryKeyFactory;   break;
+                            case 'u':   depFactory=&uniqueFactory;       break;
+                            default:    break;
+                        }
+                        break;
+                    }
+                    case 'A':
+                    {
+                        // Include only functions
+                        if (set->GetVal(wxT("adbin")).StartsWith(wxT("{FUNCEXPR")))
+                        {
+                            depFactory=&functionFactory;
+                            refname = set->GetVal(wxT("adsrc"));
+                            break;
+                        }
+                        else
+                        {
+                            set->MoveNext();
+                            continue;
+                        }
+                    }
+                    default:
+                        break;
+                }
+
+                refname += _refname;
+
+                wxString typname;
+                int icon;
+                if (depFactory)
+                {
+                    //typname = depFactory->GetTypeName();
+					d->objTypeName = depFactory->GetTypeName();
+                    icon = depFactory->GetIconId();
+                }
+                else
+                {
+                    typname = _("Unknown");
+                    icon=-1;
+                }
+
+                wxString deptype;
+
+                switch (set->GetVal(wxT("deptype")).c_str()[0])
+                {
+                    case 'n':   deptype=wxT("normal");      break;
+                    case 'a':   deptype=wxT("auto");        break;
+                    case 'i': 
+                    {
+                        if (settings->GetShowSystemObjects())
+                            deptype=wxT("internal");
+                        else
+                        {
+                            set->MoveNext();
+                            continue;
+                        }
+                        break;
+                    }
+                    case 'p':   deptype=wxT("pin");  typname=wxEmptyString;        break;
+                    default:                                break;
+                }
+
+				depList.Add(d);
+                set->MoveNext();
+            }
+            delete set;
+        }
+    }
+}
+void DiffObject::GetDependents(pgObject * obj,DependentObjArray &depList,const wxString &wh)
+{
+    wxString where;
+	wxString name = obj->GetName();
+	
+    if (wh.IsEmpty())
+        where = wxT(" WHERE dep.refobjid=") + obj->GetOidStr();
+    else
+        where = wh;
+    
+
+	wxString query;
+	FetchDep(obj,wxT("SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc, \n")
+        wxT("       CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.objsubid::text, '')\n")
+        wxT("            WHEN tg.oid IS NOT NULL THEN 'T'::text\n")
+        wxT("            WHEN ty.oid IS NOT NULL THEN 'y'::text\n")
+        wxT("            WHEN ns.oid IS NOT NULL THEN 'n'::text\n")
+        wxT("            WHEN pr.oid IS NOT NULL THEN 'p'::text\n")
+        wxT("            WHEN la.oid IS NOT NULL THEN 'l'::text\n")
+        wxT("            WHEN rw.oid IS NOT NULL THEN 'R'::text\n")
+        wxT("            WHEN co.oid IS NOT NULL THEN 'C'::text || contype\n")
+        wxT("            WHEN ad.oid IS NOT NULL THEN 'A'::text\n")
+        wxT("            ELSE '' END AS type,\n")
+        wxT("       COALESCE(coc.relname, clrw.relname) AS ownertable,\n")
+        wxT("       CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname \n")
+        wxT("            ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname) \n")
+        wxT("       END AS refname,\n")
+        wxT("       COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname\n")
+        wxT("  FROM pg_depend dep\n")
+        wxT("  LEFT JOIN pg_class cl ON dep.objid=cl.oid\n")
+        wxT("  LEFT JOIN pg_attribute att ON dep.objid=att.attrelid AND dep.objsubid=att.attnum\n")
+        wxT("  LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid\n")
+        wxT("  LEFT JOIN pg_proc pr ON dep.objid=pr.oid\n")
+        wxT("  LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid\n")
+        wxT("  LEFT JOIN pg_trigger tg ON dep.objid=tg.oid\n")
+        wxT("  LEFT JOIN pg_type ty ON dep.objid=ty.oid\n")
+        wxT("  LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid\n")
+        wxT("  LEFT JOIN pg_constraint co ON dep.objid=co.oid\n")
+        wxT("  LEFT JOIN pg_class coc ON co.conrelid=coc.oid\n")
+        wxT("  LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid\n")
+        wxT("  LEFT JOIN pg_rewrite rw ON dep.objid=rw.oid\n")
+        wxT("  LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class\n")
+        wxT("  LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid\n")
+        wxT("  LEFT JOIN pg_language la ON dep.objid=la.oid\n")
+        wxT("  LEFT JOIN pg_namespace ns ON dep.objid=ns.oid\n")
+        wxT("  LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid\n")
+        + where, wxT("classid"),depList);
+}
diff --git a/pgadmin/sv/svDiffSystem.cpp b/pgadmin/sv/svDiffSystem.cpp
new file mode 100644
index 0000000..0d4a874
--- /dev/null
+++ b/pgadmin/sv/svDiffSystem.cpp
@@ -0,0 +1,368 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDiffSystem.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDiffSystem.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include"pgAdmin3.h"
+
+#include "sv/svDiffSystem.h"
+#include "sv/svDbDiff.h"
+#include "sv/svSchemaDiff.h"
+
+////////////////////////////////////////
+// images headers
+////////////////////////////////////////
+// schema
+#include "images/sv/schema_present_sm.xpm"
+#include "images/sv/schema_missing_sm.xpm"
+#include "images/sv/schema_changed_sm.xpm"
+// tables
+#include "images/sv/table_present_sm.xpm"
+#include "images/sv/table_missing_sm.xpm"
+#include "images/sv/table_changed_sm.xpm"
+// views
+#include "images/sv/view_present_sm.xpm"
+#include "images/sv/view_missing_sm.xpm"
+#include "images/sv/view_changed_sm.xpm"
+// columns
+#include "images/sv/column_present_sm.xpm"
+#include "images/sv/column_missing_sm.xpm"
+#include "images/sv/column_changed_sm.xpm"
+
+//rule
+#include "images/sv/rule_present_sm.xpm"
+#include "images/sv/rule_missing_sm.xpm"
+#include "images/sv/rule_changed_sm.xpm"
+
+// constraints - pk
+#include "images/sv/pk_present_sm.xpm"
+#include "images/sv/pk_missing_sm.xpm"
+#include "images/sv/pk_changed_sm.xpm"
+
+// constraints - fk
+#include "images/sv/fk_present_sm.xpm"
+#include "images/sv/fk_missing_sm.xpm"
+#include "images/sv/fk_changed_sm.xpm"
+
+// constraints - index
+#include "images/sv/index_present_sm.xpm"
+#include "images/sv/index_missing_sm.xpm"
+#include "images/sv/index_changed_sm.xpm"
+// constraints - unique
+#include "images/sv/unique_present_sm.xpm"
+#include "images/sv/unique_missing_sm.xpm"
+#include "images/sv/unique_changed_sm.xpm"
+
+// roots
+//#include "images/chgdatabases-sm.xpm"
+#include "images/sv/schemas_changed_sm.xpm"
+#include "images/sv/tables_changed_sm.xpm"
+#include "images/sv/views_changed_sm.xpm"
+#include "images/sv/columns_changed_sm.xpm"
+#include "images/sv/indexes_changed_sm.xpm"
+#include "images/sv/constraints_changed_sm.xpm"
+#include "images/sv/rules_changed_sm.xpm"
+/////////////////////////////////////////
+#include "images/namespaces.xpm"
+#include "images/constraints.xpm"
+#include "images/columns.xpm"
+#include "images/tables.xpm"
+#include "images/views.xpm"
+#include "images/indexes.xpm"
+
+
+DiffImages svImages;
+//ScriptSys scriptsys; // scripts system is global
+
+
+void DiffSystem::SetDatabase(pgDatabase *src, pgDatabase *trg)
+{
+	srcdb=src;
+	trgdb=trg;
+
+}
+void DiffSystem::Initialize(ctlTree * treectrlsrcdb, ctlTree * treectrltrgdb)
+{
+	bSync = false;
+
+	sourcetree = treectrlsrcdb;
+	targettree = treectrltrgdb;
+	
+	scrSys = new ScriptSys();
+	// Initializing the script system
+	scrSys->Initialize(this->trgdb);
+	
+	diffsrc = new DbDiff(this->srcdb);
+	difftrg = new DbDiff(this->trgdb);
+
+	// Initializing the Diff Images List
+	 LoadDiffSystemImages();
+
+	// loading the diff db structure, going through the already loaded tree 
+	diffsrc->LoadDiffSystemObjects(srcdb->GetId(), treectrlsrcdb);
+	difftrg->LoadDiffSystemObjects(trgdb->GetId(), treectrltrgdb);
+}
+void DiffSystem::GenSrcDiff(wxTreeItemId item)
+{
+ 	pgObject *data = sourcetree->GetObject(item);
+
+	if(data->IsCollection())
+	{
+		if( data->GetName() == wxT("Schemas"))
+		{
+			if(!data->GetExpandedStatus())
+			{
+				data->SetExpandedStatus();
+				diffsrc->GenStructuralDiff(difftrg,sourcetree,targettree,NULL,scrSys->GetDbScript()); // finding schema level diff
+				SetDiffTaken(true);
+			}
+		}
+	}
+}
+
+ctlTree *DiffSystem::GetSourceTree(){
+	return this->sourcetree;
+}
+ctlTree *DiffSystem::GetTargetTree(){
+	return this->targettree;
+}
+void DiffSystem::LoadDiffSystemImages()
+{
+	// schemas
+	svImages.IMG_SCH_PRES = imageList->Add(wxIcon(schema_present_sm_xpm)); 
+	svImages.IMG_SCH_MISS = imageList->Add(wxIcon(schema_missing_sm_xpm)); 
+	svImages.IMG_SCH_CHG = imageList->Add(wxIcon(schema_changed_sm_xpm)); 
+	svImages.IMG_SCHEMAS_CHG = imageList->Add(wxIcon(schemas_changed_sm_xpm)); 
+	
+	// tables
+	svImages.IMG_TABLE_PRES = imageList->Add(wxIcon(table_present_sm_xpm)); 
+	svImages.IMG_TABLE_MISS = imageList->Add(wxIcon(table_missing_sm_xpm));
+	svImages.IMG_TABLE_CHG = imageList->Add(wxIcon(table_changed_sm_xpm)); 
+	svImages.IMG_TABLES_CHG = imageList->Add(wxIcon(tables_changed_sm_xpm));
+
+	// views
+	svImages.IMG_VIEW_PRES = imageList->Add(wxIcon(view_present_sm_xpm)); 
+	svImages.IMG_VIEW_MISS = imageList->Add(wxIcon(view_missing_sm_xpm)); 
+	svImages.IMG_VIEW_CHG = imageList->Add(wxIcon(view_changed_sm_xpm)); 
+	svImages.IMG_VIEWS_CHG = imageList->Add(wxIcon(views_changed_sm_xpm)); 
+	
+	// columns
+	svImages.IMG_COLUMN_PRES = imageList->Add(wxIcon(column_present_sm_xpm)); 
+	svImages.IMG_COLUMN_MISS = imageList->Add(wxIcon(column_missing_sm_xpm)); 
+	svImages.IMG_COLUMN_CHG = imageList->Add(wxIcon(column_changed_sm_xpm)); 
+	svImages.IMG_COLUMNS_CHG = imageList->Add(wxIcon(columns_changed_sm_xpm));
+
+	// rule
+	svImages.IMG_RULE_PRES = imageList->Add(wxIcon(rule_present_sm_xpm)); 
+	svImages.IMG_RULE_MISS = imageList->Add(wxIcon(rule_missing_sm_xpm)); 
+	svImages.IMG_RULE_CHG = imageList->Add(wxIcon(rule_changed_sm_xpm)); 
+	svImages.IMG_RULES_CHG = imageList->Add(wxIcon(rules_changed_sm_xpm));
+
+	// index
+	svImages.IMG_INDEX_PRES = imageList->Add(wxIcon(index_present_sm_xpm)); 
+	svImages.IMG_INDEX_MISS = imageList->Add(wxIcon(index_missing_sm_xpm)); 
+	svImages.IMG_INDEX_CHG = imageList->Add(wxIcon(index_changed_sm_xpm)); 
+	svImages.IMG_INDEXES_CHG = imageList->Add(wxIcon(indexes_changed_sm_xpm)); 
+
+	// pk
+    svImages.IMG_PK_PRES = imageList->Add(wxIcon(pk_present_sm_xpm)); 
+	svImages.IMG_PK_MISS = imageList->Add(wxIcon(pk_missing_sm_xpm)); 
+	svImages.IMG_PK_CHG = imageList->Add(wxIcon(pk_changed_sm_xpm)); 
+
+	// fk
+	svImages.IMG_FK_PRES = imageList->Add(wxIcon(fk_present_sm_xpm)); 
+	svImages.IMG_FK_MISS = imageList->Add(wxIcon(fk_missing_sm_xpm)); 
+	svImages.IMG_FK_CHG = imageList->Add(wxIcon(fk_changed_sm_xpm)); 
+	
+	// unique
+	svImages.IMG_UNIQUE_PRES = imageList->Add(wxIcon(unique_present_sm_xpm)); 
+	svImages.IMG_UNIQUE_MISS = imageList->Add(wxIcon(unique_missing_sm_xpm)); 
+	svImages.IMG_UNIQUE_CHG = imageList->Add(wxIcon(unique_changed_sm_xpm));
+
+	// constraint
+	svImages.IMG_CONSTRAINTS_CHG = imageList->Add(wxIcon(constraints_changed_sm_xpm));
+
+	// unchanged
+	svImages.IMG_SCHEMAS = imageList->Add(wxIcon(namespaces_xpm)); 
+	svImages.IMG_TABLES = imageList->Add(wxIcon(tables_xpm)); 
+	svImages.IMG_VIEWS = imageList->Add(wxIcon(views_xpm));
+	svImages.IMG_COLUMNS = imageList->Add(wxIcon(columns_xpm)); 
+	svImages.IMG_CONSTRAINTS = imageList->Add(wxIcon(constraints_xpm)); 
+	svImages.IMG_INDEXES = imageList->Add(wxIcon(indexes_xpm));
+}
+
+bool DiffSystem::ApplyDiff()
+{
+	bool success=false;
+
+	if(IsDiffTaken())
+	{
+		if(!scrSys->IsCompiled()) // if not already collated , do it
+			this->diffScript = scrSys->CompileScript();
+	}
+	else
+	{
+		diffsrc->GenStructuralDiff(difftrg,sourcetree,targettree,NULL,scrSys->GetDbScript()); // finding schema level diff
+		SetDiffTaken(true);
+
+		this->diffScript = scrSys->CompileScript();
+		scrSys->SetScriptCompiled(true);
+	}
+	
+	if(this->diffScript.length()>0)
+	{
+		success = scrSys->ApplyScript(this->diffScript);
+		if(success)
+		{
+			this->bSync=true;
+			wxMessageBox(wxT("Difference Applied Successfully!"), wxT("Information"), wxOK | wxICON_INFORMATION, NULL);
+		}
+	}
+	else
+		wxMessageBox(wxT("No Difference Exist!"), wxT("Information"), wxOK | wxICON_INFORMATION, NULL);
+
+	return success; 
+}
+DiffObject *DiffSystem::GetSrcTableObject(wxString schName,wxString tabName)
+{
+	SchemaDiff * srcSchema =diffsrc->FindObj(schName);
+	TableDiff * srcTable = (TableDiff*)srcSchema->FindObj(tabName,PGM_TABLE);
+	if(srcTable)
+		return srcTable;
+	else
+		return 0;
+}
+bool DiffSystem::IsDiffExist()
+{
+	if(this->diffScript.length()>0)
+		return true;
+	else
+		return false;
+}
+DiffObject *DiffSystem::GetTrgTableObject(wxString schName,wxString tabName)
+{
+	SchemaDiff * trgSchema = difftrg->FindObj(schName);
+	TableDiff * trgTable = (TableDiff*)trgSchema->FindObj(tabName,PGM_TABLE);
+	if(trgTable)
+		return trgTable;
+	else
+		return 0;
+}
+bool DiffSystem::ShowDiffGrid(pgObject * selObj, wxGrid * grid)
+{
+	return this->scrSys->ShowDiff(selObj,grid,bSync);
+}
+TableScript *DiffSystem::GetTableScriptHandle()
+{
+	return this->scrSys->GetTableScriptHandle();
+}
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////
+bool ScriptSys::ApplyScript(wxString diffScript)
+{
+	// do error handling here
+
+	bool status = trgDb->ExecuteVoid(diffScript);
+	return status;
+}
+
+wxString ScriptSys::CompileScript()
+{
+	wxString createScript;
+	wxString alterScript;
+	wxString fkScripts;
+	wxString dropScript;
+	wxString diffScripts,tmp;
+	
+	tmp = GenerateDropScripts();
+	if(tmp.length()>0)
+	{
+		dropScript+=wxT("\n");
+		dropScript=tmp;
+	}
+	tmp = GenerateCreateScripts();
+	if(tmp.length()>0)
+		createScript=tmp;
+	
+	tmp = GenerateAlterScripts();
+	if(tmp.length()>0)
+	{
+		alterScript+=wxT("\n");
+		alterScript=tmp;
+	}
+	tmp = GenerateFkScripts();
+	if(tmp.length()>0)
+	{
+		fkScripts+=wxT("\n");
+		fkScripts=tmp;
+	}
+	
+	diffScripts=createScript+alterScript+fkScripts+dropScript;
+	diffScripts=RemoveCarriageRet(diffScripts);
+
+	wxFile file;
+	file.Open(wxT("E:/script.txt"),wxFile::read_write,32);
+	//file.Create(wxT("script.txt"),true,wxS_DEFAULT);
+	if(file.IsOpened())
+	{
+		//printf(h.c_str());
+		size_t f= file.Write(dropScript);
+		/*if(f>0)
+			wxMessageBox(wxT("Scripts Generated"), wxT("Info"), wxOK | wxICON_INFORMATION, NULL);*/
+	}
+	return diffScripts;
+}
+wxString ScriptSys::GenerateCreateScripts()
+{
+	wxString createScript;
+	createScript = dbScript->GenerateCreateScript();
+	return createScript;
+}
+
+wxString ScriptSys::GenerateAlterScripts()
+{
+	wxString alterScript;
+	alterScript = dbScript->GenerateAlterScript();
+	return alterScript;
+}
+
+wxString ScriptSys::GenerateDropScripts()
+{
+	wxString dropScript;
+	dropScript = dbScript->GenerateDropScript();
+	return dropScript;
+}
+wxString ScriptSys::GenerateFkScripts()
+{
+	wxString fkScript;
+	fkScript = dbScript->GenerateFkScripts();
+	return fkScript;
+
+}
+void ScriptSys::Initialize(pgDatabase *target)
+{
+	trgDb = target;
+	dbScript = new DbScript();
+	dbScript->Initialize();
+}
+wxString ScriptSys::RemoveCarriageRet(wxString str)
+{
+	wxString tmp;
+	str.Replace(wxT("\n"),wxT(""));
+	tmp=str;
+	return tmp;
+}
+bool ScriptSys::ShowDiff(pgObject * selObj, wxGrid * grid,bool bSync)
+{
+	TableScript * tabScr = this->dbScript->GetSchemaScriptHandle()->GetTableScriptHandle();
+	return tabScr->ShowDiff(selObj,grid,bSync);
+}
+TableScript *ScriptSys::GetTableScriptHandle()
+{
+	return this->dbScript->GetSchemaScriptHandle()->GetTableScriptHandle();
+}
diff --git a/pgadmin/sv/svDropColumn.cpp b/pgadmin/sv/svDropColumn.cpp
new file mode 100644
index 0000000..6050b48
--- /dev/null
+++ b/pgadmin/sv/svDropColumn.cpp
@@ -0,0 +1,52 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropColumn.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropColumn.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgColumn.h"
+#include "sv/svDropColumn.h"
+
+
+
+DropColumn::DropColumn(DiffObject * obj)
+{
+	column = ((ColumnDiff*)obj)->GetColumn();
+	SetColumnName(column->GetName());
+	SetTableName(column->GetTable()->GetName());
+	SetSchemaName(column->GetSchema()->GetName());
+	SetVarTypeName(column->GetVarTypename());
+	column->SetPK(); // initializing the column PK
+	SetIsPK(column->GetIsPK());
+	SetIsFK(column->GetIsFK());
+	SetNotNull(column->GetNotNull());
+	
+	SetMetaType(DROPCOLUMN);
+
+	bColDepIndex = false;
+	bColDepFk = false;
+	bColDepPk = false;
+	bColDepUnique = false;
+	bColDepView = false;
+}
+void DropColumn::GenerateScript()
+{
+	wxString sqlScript;
+	wxString qualifiedName;
+	if(GetSchemaName()!=wxT("public"))
+		qualifiedName =wxT("\"")+ GetSchemaName()+wxT("\".\"")+ GetTableName()+wxT("\"");
+	else
+		qualifiedName = wxT("\"")+GetTableName()+wxT("\""); // by default , schema is public
+	// dropping the column
+	sqlScript+=wxT(" ALTER TABLE ")+ qualifiedName + wxT(" DROP COLUMN \"")+
+			GetColumnName()+wxT("\";");
+		
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svDropFk.cpp b/pgadmin/sv/svDropFk.cpp
new file mode 100644
index 0000000..d390c36
--- /dev/null
+++ b/pgadmin/sv/svDropFk.cpp
@@ -0,0 +1,53 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropFk.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropFk.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgForeignKey.h"
+#include "sv/svDropFk.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svFkDiff.h"
+
+
+DropFk::DropFk(DiffObject * obj)
+{
+	fk = ((FkDiff*)obj)->GetFk();
+	SetFkName(fk->GetName());
+	SetTableName(fk->GetTable()->GetName());
+	SetSchemaName(fk->GetSchema()->GetName());
+	SetMetaType(DROPFK);
+}
+DropFk::DropFk(wxString tableName,wxString objName,wxString schemaName)
+{
+	SetFkName(objName);
+	SetTableName(tableName);
+	if(schemaName.length()==0) // no schema is mention, by default publi
+		schemaName=wxT("public");
+	SetSchemaName(schemaName);
+	SetMetaType(DROPFK);
+}
+
+void DropFk::GenerateScript()
+{
+	wxString qualifiedName;
+	if(GetSchemaName()!=wxT("public"))
+		qualifiedName = fk->GetSchema()->GetName()+wxT(".")+ GetTableName();
+	else
+		qualifiedName = GetTableName(); // by default , schema is public
+
+	sqlScript+= wxT("ALTER TABLE \"")+ qualifiedName +wxT("\" DROP CONSTRAINT \"") + 
+		GetFkName()+wxT("\";"); 
+	SetScript(sqlScript);
+	
+}
+void DropFk::ApplyScript()
+{
+}
diff --git a/pgadmin/sv/svDropIndex.cpp b/pgadmin/sv/svDropIndex.cpp
new file mode 100644
index 0000000..a33dd66
--- /dev/null
+++ b/pgadmin/sv/svDropIndex.cpp
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropIndex.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropIndex.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgIndex.h"
+#include "sv/svDropIndex.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svIndexDiff.h"
+
+
+DropIndex::DropIndex(DiffObject *obj)
+{
+	index =((IndexDiff*)obj)->GetIndex();
+	SetIndexName(index->GetName());
+	SetSchemaName(index->GetSchema()->GetName());
+	SetTableName(index->GetTable()->GetName());
+	SetMetaType(DROPINDEX);
+}
+DropIndex::DropIndex(wxString tableName,wxString objName,wxString schemaName)
+{
+	SetIndexName(objName);
+	SetTableName(tableName);
+	if(schemaName.length()==0) // no schema is mention, by default publi
+		schemaName=wxT("public");
+	SetSchemaName(schemaName);
+	SetMetaType(DROPINDEX);
+}
+
+void DropIndex::GenerateScript()
+{
+	// as there are changes , drop the existing index and creating a new one
+	wxString sqlScript;
+	//index->ReadIndexColumnInfo();
+	sqlScript+=wxT(" DROP INDEX \"")+GetSchemaName()+wxT("\".")+GetIndexName()+wxT(";\n");
+	// creating index
+	//sqlScript += index->GetCreate();
+	SetScript(sqlScript);
+}
+
diff --git a/pgadmin/sv/svDropPk.cpp b/pgadmin/sv/svDropPk.cpp
new file mode 100644
index 0000000..903911b
--- /dev/null
+++ b/pgadmin/sv/svDropPk.cpp
@@ -0,0 +1,53 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropPk.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropPk.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgPrimaryKey.h"
+#include "sv/svDropPk.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svPkDiff.h"
+
+
+DropPk::DropPk(DiffObject *obj)
+{
+	pk = ((PkDiff*)obj)->GetPk();
+	SetPkName(pk->GetName());
+	SetTableName(pk->GetTable()->GetName());
+	SetSchemaName(pk->GetSchema()->GetName());
+	SetMetaType(DROPPK);
+	bPkDepFk=false;
+}
+DropPk::DropPk(wxString tableName,wxString objName,wxString schemaName)
+{
+	SetPkName(objName);
+	SetTableName(tableName);
+	if(schemaName.length()==0) // no schema is mention, by default publi
+		schemaName=wxT("public");
+	SetSchemaName(schemaName);
+	SetMetaType(DROPPK);
+	bPkDepFk=false;
+}
+void DropPk::GenerateScript()
+{
+	wxString sqlScript;
+	
+	wxString qualifiedName;
+	if(GetSchemaName()!=wxT("public"))
+		qualifiedName = wxT("\"")+GetSchemaName()+wxT("\".\"")+ GetTableName()+wxT("\"");
+	else
+		qualifiedName = wxT("\"")+GetTableName()+wxT("\""); // by default , schema is public
+
+	sqlScript +=wxT("ALTER TABLE ")+qualifiedName+wxT(" DROP CONSTRAINT \"")+
+		GetPkName()+wxT("\"; ");
+	SetScript(sqlScript);
+	
+}
diff --git a/pgadmin/sv/svDropRule.cpp b/pgadmin/sv/svDropRule.cpp
new file mode 100644
index 0000000..afc8c1a
--- /dev/null
+++ b/pgadmin/sv/svDropRule.cpp
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropRule.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropRule.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgRule.h"
+#include "sv/svDropRule.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svRuleDiff.h"
+
+DropRule::DropRule(DiffObject *obj)
+{
+	rule = ((RuleDiff*)obj)->GetRule();
+	SetRuleName(rule->GetName());
+	//SetViewName(rule->GetTable()->GetName());
+	SetSchemaName(rule->GetSchema()->GetName());
+	SetMetaType(DROPRULE);
+	//bPkDepRule=false;
+}
+DropRule::DropRule(wxString viewName,wxString objName,wxString schemaName)
+{
+	SetRuleName(objName);
+	//SetViewName(viewName);
+	if(schemaName.length()==0) // no schema is mention, by default public
+		schemaName=wxT("public");
+	SetSchemaName(schemaName);
+	SetMetaType(DROPRULE);
+	//bPkDepRule=false;
+}
+void DropRule::GenerateScript()
+{
+	wxString sqlScript;
+	//SetScript(sqlScript);
+	
+}
diff --git a/pgadmin/sv/svDropSchema.cpp b/pgadmin/sv/svDropSchema.cpp
new file mode 100644
index 0000000..c32a1a6
--- /dev/null
+++ b/pgadmin/sv/svDropSchema.cpp
@@ -0,0 +1,31 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropSchema.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropSchema.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgSchema.h"
+#include "sv/svDropSchema.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svSchemaDiff.h"
+
+
+DropSchema::DropSchema(DiffObject * obj)
+{
+	schema = ((SchemaDiff*)obj)->GetSchema();
+	SetSchemaName(schema->GetName());
+	SetMetaType(DROPSCHEMA);
+}
+void DropSchema::GenerateScript()
+{
+	wxString sqlScript;
+	sqlScript+=wxT(" DROP SCHEMA \"")+GetSchemaName()+wxT("\";\n");
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svDropTable.cpp b/pgadmin/sv/svDropTable.cpp
new file mode 100644
index 0000000..f3dbcad
--- /dev/null
+++ b/pgadmin/sv/svDropTable.cpp
@@ -0,0 +1,40 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropTable.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropTable.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgTable.h"
+#include "sv/svDropTable.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svTableDiff.h"
+
+
+DropTable::DropTable(DiffObject *obj)
+{
+	table = ((TableDiff*)obj)->GetTable();
+	SetSchemaName(table->GetSchema()->GetName());
+	SetTableName(table->GetName());
+	
+	SetMetaType(DROPTABLE);
+}
+void DropTable::GenerateScript()
+{
+	wxString sqlScript;
+	
+	wxString qualifiedName;
+	if(GetSchemaName()!=wxT("public"))
+		qualifiedName = wxT("\"")+GetSchemaName()+wxT("\".\"")+ GetTableName()+wxT("\"");
+	else
+		qualifiedName = wxT("\"")+GetTableName()+wxT("\""); // by default , schema is public
+
+	sqlScript+=wxT(" DROP TABLE ")+ qualifiedName + wxT(";\n");
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svDropUnique.cpp b/pgadmin/sv/svDropUnique.cpp
new file mode 100644
index 0000000..e201f07
--- /dev/null
+++ b/pgadmin/sv/svDropUnique.cpp
@@ -0,0 +1,52 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropUnique.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropUnique.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgUnique.h"
+#include "sv/svDropUnique.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svUniqueDiff.h"
+
+
+DropUnique::DropUnique(DiffObject * obj)
+{
+	unique = ((UniqueDiff*)obj)->GetUnique();
+	SetUniqueName(unique->GetName());
+	SetTableName(unique->GetTable()->GetName());
+	SetSchemaName(unique->GetSchema()->GetName());
+	SetMetaType(DROPUNIQUE);
+	bUniqueDepFk=false;
+}
+DropUnique::DropUnique(wxString tableName,wxString objName,wxString schemaName)
+{
+	SetUniqueName(objName);
+	SetTableName(tableName);
+	if(schemaName.length()==0) // no schema is mention, by default publi
+		schemaName=wxT("public");
+	SetSchemaName(schemaName);
+	SetMetaType(DROPUNIQUE);
+	bUniqueDepFk=false;
+}
+
+void DropUnique::GenerateScript()
+{
+	wxString sqlScript;
+	wxString qualifiedName;
+
+	if(GetSchemaName()!=wxT("public"))
+		qualifiedName = wxT("\"")+GetSchemaName()+wxT("\".\"")+ GetTableName()+wxT("\"");
+	else
+		qualifiedName = wxT("\"")+GetTableName()+wxT("\""); // by default , schema is public
+	sqlScript+=wxT(" ALTER TABLE ")+qualifiedName+wxT(" DROP CONSTRAINT \"")+
+		     GetUniqueName()+wxT("\";\n ");
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svDropView.cpp b/pgadmin/sv/svDropView.cpp
new file mode 100644
index 0000000..f7265b8
--- /dev/null
+++ b/pgadmin/sv/svDropView.cpp
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svDropView.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svDropView.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "schema/pgView.h"
+#include "sv/svDropView.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svViewDiff.h"
+
+DropView::DropView(DiffObject *obj)
+{
+	view = ((ViewDiff*)obj)->GetView();
+	SetSchemaName(view->GetSchema()->GetName());
+	SetViewName(view->GetName());
+	
+	SetMetaType(DROPVIEW);
+}
+DropView::DropView(wxString viewName,wxString schemaName)
+{
+	SetViewName(viewName);
+	
+	if(schemaName.length()==0) // no schema is mention, by default publi
+		schemaName=wxT("public");
+	SetSchemaName(schemaName);
+	SetMetaType(DROPVIEW);
+}
+void DropView::GenerateScript()
+{
+	wxString sqlScript;
+	sqlScript+=wxT("DROP VIEW ") + GetSchemaName() + wxT(".") + GetViewName()+wxT(";\n");
+	SetScript(sqlScript);
+}
diff --git a/pgadmin/sv/svFKDiff.cpp b/pgadmin/sv/svFKDiff.cpp
new file mode 100644
index 0000000..ed8cf26
--- /dev/null
+++ b/pgadmin/sv/svFKDiff.cpp
@@ -0,0 +1,217 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svFkDiff.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svFkDiff.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include"pgAdmin3.h"
+
+#include"sv/svFKDiff.h"
+#include"sv/svDiffSystem.h"
+#include"sv/svDropFk.h"
+#include"sv/svAlterFk.h"
+
+bool FkDiff::GenStructuralDiff(DiffObject * trgFKC,ctlTree * src, ctlTree * trg,wxTreeItemId dummyId,FkScript *fkScr)
+{
+	FkDiff * trgFk = (FkDiff*)trgFKC;
+	pgForeignKey *pgf = trgFk->GetFk();
+	pgForeignKey * srcFk = (pgForeignKey*)this->GetObject();
+
+	wxString name0 = srcFk->GetName();
+	wxString name1 = pgf->GetName();
+	wxString sch0 = srcFk->GetSchema()->GetName();
+	wxString sch1 = pgf->GetSchema()->GetName();
+
+	// initializing columns
+	srcFk->ReadFkColumnInfo();
+	pgf->ReadFkColumnInfo();
+
+	
+	
+	int obj = fkScr->SearchObject(pgf->GetTable()->GetName(),pgf->GetName(),DROPFK,pgf->GetSchema()->GetName());
+	if(obj==wxNOT_FOUND)
+	{
+		if(srcFk->GetRefSchema()!=pgf->GetRefSchema() ||
+		srcFk->GetReferences()!=pgf->GetReferences()/* || 
+		srcFk->GetFkColumns()!=pgf->GetFkColumns()*/)
+		{
+			FkElement * alterFk = new AlterFk(trgFk);
+
+			((AlterFk*)alterFk)->setAlterCase(wxT("Overwrite")); // drop and add
+			((AlterFk*)alterFk)->GenerateScript();
+			fkScr->AddDiffElement(alterFk);
+	
+		
+			// UI changes
+			////////////////////////////////////
+			trg->SetItemImage(pgf->GetId(),svImages.IMG_FK_CHG);
+			wxTreeItemId id = trg->GetItemParent(pgf->GetId());
+			trg->SetItemImage(id,svImages.IMG_CONSTRAINTS_CHG);
+			/////////////////////////////////////
+			return true;
+		}
+	}
+	else 
+	{
+		/* if the drop fk is already in the list, this is a special case in because that shows
+		the column is being dropped along with the attached fk,but the new added fk has the same name
+		so no need to drop it.
+		*/
+		FkElement * alterFk = new AlterFk(trgFk);
+		((AlterFk*)alterFk)->setAlterCase(wxT("Add"));
+		((AlterFk*)alterFk)->GenerateScript();
+		fkScr->AddDiffElement(alterFk);
+	
+	}
+	// finding difference
+
+	wxString aS=srcFk->GetRefSchema();
+	wxString aT=pgf->GetRefSchema();
+
+	wxString bS=srcFk->GetReferences();
+	wxString bT=pgf->GetReferences();
+	
+	wxString cS=srcFk->GetFkColumns();
+	wxString cT=pgf->GetFkColumns();
+
+	wxString dS=srcFk->GetCoveringIndex();
+	wxString dT=pgf->GetCoveringIndex();
+
+	return false;
+}
+////////////////////////////////////////////////////////////////////////
+void FkScript::GenerateScript()
+{
+
+}
+wxString FkScript::GenerateCreateScript(wxString tableName,wxString schemaName)
+{
+	wxString createFkScript;
+	for(size_t i=0; i<this->fkDiffList.GetCount();i++)
+	{
+		FkElement *fkElem = this->fkDiffList.Item(i);
+		if(fkElem->GetMetaType() == CRTFK && 
+			fkElem->GetTableName() == tableName &&
+			fkElem->GetSchemaName() == schemaName)
+		{
+			createFkScript+=fkElem->GetScript();
+			if(createFkScript.length()>0)
+				createFkScript+=wxT(";");
+		}
+	}
+	return createFkScript;
+}
+wxString FkScript::GenerateAlterScript(wxString &tableName,wxString &schemaName,wxString ObjType)
+{
+	int SearchMetaType;
+	if(ObjType == wxT("DROP")) // fetch only drop elements
+		SearchMetaType = DROPFK;
+	else
+		SearchMetaType = ADDFK; 
+
+	// have to fix this
+	// temp arrangement
+	wxString tabName=tableName;
+	wxString schName=schemaName;
+	
+	wxString alterFkScript,tmp;
+	for(size_t i=0; i<this->fkDiffList.GetCount();i++)
+	{
+		
+		FkElement *fkElem = this->fkDiffList.Item(i);
+
+
+		int m = fkElem->GetMetaType();
+		wxString fkname= fkElem->GetFkName();
+		wxString schemaName = fkElem->GetSchemaName();
+		wxString tableName = fkElem->GetTableName();
+		
+		if((fkElem->GetMetaType() == SearchMetaType || fkElem->GetMetaType() == ALTERFK) && 
+			fkElem->GetTableName() == tabName && 
+			fkElem->GetSchemaName() == schName)
+		{
+			if(fkElem->GetMetaType()==DROPFK )
+
+			{
+				if(!fkElem->IsAlreadyApplied())
+				{
+					alterFkScript+=fkElem->GetScript();
+					if(alterFkScript.length()>0)
+					alterFkScript+=wxT(";");
+				}
+			}
+			else if(fkElem->GetMetaType()==ALTERFK || fkElem->GetMetaType()==ADDFK)
+			{
+				alterFkScript+=fkElem->GetScript();
+				if(alterFkScript.length()>0)
+					alterFkScript+=wxT(";");
+			}
+		}
+	}
+	return alterFkScript;
+}
+wxString FkScript::GenerateDropScript(wxString tableName,wxString schemaName)
+{
+	wxString dropFkScript,tmp;
+	for(size_t i=0; i<this->fkDiffList.GetCount();i++)
+	{
+		FkElement *fkElem = this->fkDiffList.Item(i);
+		if(fkElem->GetMetaType()==DROPFK && 
+			fkElem->GetTableName() == tableName && 
+			fkElem->GetSchemaName() == schemaName)
+		{
+			if(!fkElem->IsAlreadyApplied())
+			{
+				tmp=fkElem->GetScript();
+				if(tmp.length()>0)
+				{
+					dropFkScript+=tmp;
+					dropFkScript+=wxT(";");
+				}
+			}
+		}
+	}
+	return dropFkScript;
+}
+
+void FkScript::ApplyScript()
+{}
+void FkScript::AddDiffElement(FkElement * de)
+{
+	this->fkDiffList.Add(de);
+}
+int FkScript::SearchObject(wxString tableName,wxString objName,int metaType,wxString schemaName)
+{
+	if(schemaName.length()==0)
+		schemaName=wxT("public");
+
+	int index=wxNOT_FOUND;
+	for(size_t i=0; i<fkDiffList.GetCount();i++)
+	{
+		FkElement * de = fkDiffList.Item(i);
+		wxString schName = de->GetSchemaName();
+		wxString tabName = de->GetTableName();
+		
+		if(de->GetMetaType() == metaType)
+		{
+			if(metaType == DROPFK) // searching for dropped fk object
+			{
+				DropFk * dfk = (DropFk*)de;
+				wxString oName = dfk->GetFkName();
+				if( dfk->GetSchemaName() == schemaName && 
+					dfk->GetTableName() == tableName &&
+					dfk->GetFkName() == objName )
+				{
+					index = fkDiffList.Index(de);
+					break;
+				}
+			}
+		}
+	}
+	return index;
+}
diff --git a/pgadmin/sv/svIndexDiff.cpp b/pgadmin/sv/svIndexDiff.cpp
new file mode 100644
index 0000000..e782bdb
--- /dev/null
+++ b/pgadmin/sv/svIndexDiff.cpp
@@ -0,0 +1,184 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svIndexDiff.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svIndexDiff.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include"pgAdmin3.h"
+
+#include "sv/svIndexDiff.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svDropIndex.h"
+#include "sv/svAlterIndex.h"
+
+bool IndexDiff::GenStructuralDiff(DiffObject * trgIndex,ctlTree * src, ctlTree * trg,wxTreeItemId dummyId,IndexScript *indexScr)
+{
+	IndexDiff * trgInd = (IndexDiff*)trgIndex;
+	pgIndex *pgi = trgInd->GetIndex();
+	
+	// finding difference
+	pgIndex * srcIndex = (pgIndex*)this->GetObject();
+
+	// initializing columns
+	srcIndex->ReadIndexColumnInfo();
+	pgi->ReadIndexColumnInfo();
+
+	
+	int obj = indexScr->SearchObject(pgi->GetTable()->GetName(),pgi->GetName(),DROPINDEX,pgi->GetSchema()->GetName());
+	if(obj==wxNOT_FOUND) // if the drop pk is not already entered by drop column
+	{
+		if(srcIndex->GetIndexType()!=pgi->GetIndexType() ||
+		srcIndex->GetIsPrimary()!=pgi->GetIsPrimary() || 
+		srcIndex->GetColumns()!=pgi->GetColumns())
+		{
+			IndexElement * alterIndex = new AlterIndex(this);
+			
+			((AlterIndex*)alterIndex)->setAlterCase(wxT("Overwrite")); // drop and add
+			((AlterIndex*)alterIndex)->GenerateScript();
+			indexScr->AddDiffElement(alterIndex);
+
+		
+			// showing present elements @ target
+			////////////////////////////////////
+			trg->SetItemImage(pgi->GetId(),svImages.IMG_INDEX_CHG);
+			wxTreeItemId id = trg->GetItemParent(pgi->GetId());
+			trg->SetItemImage(id,svImages.IMG_CONSTRAINTS_CHG);
+			/////////////////////////////////////
+			return true;
+		}
+	}
+	else 
+	{
+			/* if the drop index is already in the list, this is a special case in because that shows
+			the column is being dropped along with the attached index,but the new added fk has the same name
+			so no need to drop it.
+			*/
+			IndexElement * alterIndex = new AlterIndex(this);
+			((AlterIndex*)alterIndex)->setAlterCase(wxT("Add"));
+			((AlterIndex*)alterIndex)->GenerateScript();
+			indexScr->AddDiffElement(alterIndex);
+	}
+	return false;
+}
+///////////////////////////////////////////////////
+void IndexScript::GenerateScript()
+{
+}
+wxString IndexScript::GenerateCreateScript(wxString tableName,wxString schemaName)
+{
+	wxString createIndexScript;
+
+	if(schemaName.length()==0)
+		schemaName=wxT("public");
+	
+	for(size_t i=0; i<this->indexDiffList.GetCount();i++)
+	{
+		IndexElement *indElem = this->indexDiffList.Item(i);
+		if(indElem->GetMetaType() == CRTINDEX && 
+			indElem->GetTableName() == tableName &&
+			indElem->GetSchemaName() == schemaName)
+		{
+			createIndexScript+=indElem->GetScript();
+		}
+	}
+	return createIndexScript;
+}
+wxString IndexScript::GenerateAlterScript(wxString tableName,wxString schemaName,wxString ObjType)
+{
+	int SearchMetaType;
+	if(ObjType == wxT("DROP")) // fetch only drop elements
+		SearchMetaType = DROPINDEX;
+	else
+		SearchMetaType = ADDINDEX; 
+
+	
+	wxString alterIndexScript;
+	if(schemaName.length()==0)
+		schemaName=wxT("public");
+	
+	for(size_t i=0; i<this->indexDiffList.GetCount();i++)
+	{
+		IndexElement *indElem = this->indexDiffList.Item(i);
+		if((indElem->GetMetaType() == SearchMetaType ||indElem->GetMetaType() == ALTERINDEX)&& 
+			indElem->GetTableName() == tableName && 
+			indElem->GetSchemaName() == schemaName)
+		{
+			if(indElem->GetMetaType()==DROPINDEX &&
+				!indElem->IsAlreadyApplied())
+			{
+				alterIndexScript+=indElem->GetScript();
+			}
+			else if(indElem->GetMetaType()==ADDINDEX)
+			{
+				alterIndexScript+=indElem->GetScript();
+			}
+			else if(indElem->GetMetaType()==ALTERINDEX)
+			{
+				alterIndexScript+=indElem->GetScript();
+			}
+		}
+	}
+	return alterIndexScript;
+}
+wxString IndexScript::GenerateDropScript(wxString tableName,wxString schemaName)
+{
+	wxString dropIndexScript;
+
+	if(schemaName.length()==0)
+		schemaName=wxT("public");
+	
+	for(size_t i=0; i<this->indexDiffList.GetCount();i++)
+	{
+		IndexElement *indElem = this->indexDiffList.Item(i);
+		if(indElem->GetMetaType()==DROPINDEX && 
+			indElem->GetTableName() == tableName && 
+			indElem->GetSchemaName() == schemaName)
+		{
+			if(!indElem->IsAlreadyApplied())
+			{
+				dropIndexScript+=indElem->GetScript();
+			}
+		}
+	}
+	return dropIndexScript;
+}
+
+void IndexScript::AddDiffElement(IndexElement * de)
+{
+	this->indexDiffList.Add(de);
+}
+int IndexScript::SearchObject(wxString tableName,wxString objName,int metaType,wxString schemaName)
+{
+	if(schemaName.length()==0)
+		schemaName=wxT("public");
+
+	int index=wxNOT_FOUND;
+	for(size_t i=0; i<indexDiffList.GetCount();i++)
+	{
+		IndexElement * de = indexDiffList.Item(i);
+		wxString schName = de->GetSchemaName();
+		wxString tabName = de->GetTableName();
+		
+		if(de->GetMetaType() == metaType)
+		{
+			if(metaType == DROPINDEX) // searching for dropped fk object
+			{
+				DropIndex * dind = (DropIndex*)de;
+				wxString oName = dind->GetIndexName();
+				if( dind->GetSchemaName() == schemaName && 
+					dind->GetTableName() == tableName &&
+					dind->GetIndexName() == objName )
+				{
+					index = indexDiffList.Index(de);
+					break;
+				}
+			}
+		}
+	}
+	return index;
+}
diff --git a/pgadmin/sv/svPKDiff.cpp b/pgadmin/sv/svPKDiff.cpp
new file mode 100644
index 0000000..9f7f761
--- /dev/null
+++ b/pgadmin/sv/svPKDiff.cpp
@@ -0,0 +1,285 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svPkDiff.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svPkDiff.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "sv/svPKDiff.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svDropPk.h"
+#include "sv/svDropFk.h"
+#include "sv/svAlterPk.h"
+
+bool PkDiff::GenStructuralDiff(DiffObject * trgPKC,ctlTree * src, ctlTree * trg,wxTreeItemId dummyId,TableScript * tabScr)
+{
+	
+	PkDiff * trgPk = (PkDiff*)trgPKC;
+	pgPrimaryKey * pgp = trgPk->GetPk();
+	pgPrimaryKey * srcPk = (pgPrimaryKey*)this->GetObject();
+
+	// initializing columns
+	srcPk->ReadPkColumnInfo();
+	pgp->ReadPkColumnInfo();
+	
+	
+	/*
+	If drop case not found, then the target pk has to be dropped and then added, and dropped needs dependency checking
+	*/
+	int obj = tabScr->GetPkScript()->SearchObject(pgp->GetTable()->GetName(),pgp->GetName(),DROPPK,pgp->GetSchema()->GetName());
+	if(obj==wxNOT_FOUND) // if the drop pk is not already entered by drop column
+	{
+		if(srcPk->GetIndexType()!=pgp->GetIndexType() ||
+			srcPk->GetIsPrimary()!=pgp->GetIsPrimary() || 
+			srcPk->GetColumns()!=pgp->GetColumns())
+		{
+			// showing present elements @ target
+			//////////////////////////////////////////////
+			trg->SetItemImage(pgp->GetId(),svImages.IMG_PK_CHG);
+			wxTreeItemId id = trg->GetItemParent(pgp->GetId());
+			trg->SetItemImage(id,svImages.IMG_CONSTRAINTS_CHG);
+			/////////////////////////////////////////////
+
+			AlterPk * alterPk = new AlterPk(this);
+
+			// checking dependency and adding required dependent obj to drop this obj
+			DependentObjArray depList;
+			wxString where;
+			TableDiff::GetDependents(pgp,depList,where);
+			
+			if(!depList.IsEmpty()) // if the obj to be dropped has some dependents
+			{
+				int depIndex;
+				for(size_t i=0; i<depList.GetCount(); i++)
+				{
+					DependencyObj * dobj= (DependencyObj*)depList.Item(i);
+					if(!dobj->tableName) // tableName is empty when pk is auto type
+						dobj->tableName = pgp->GetTable()->GetName();
+					
+					if(dobj->objTypeName == wxT("Foreign Key"))
+					{
+						// already there 
+						depIndex = tabScr->GetFkScript()->SearchObject(dobj->tableName,dobj->objName,DROPFK,dobj->schemaName);
+						if(depIndex == wxNOT_FOUND) 
+						{
+							// create a drop obj for dependent and add to list
+							FkElement * dropDependent = new DropFk(dobj->tableName,dobj->objName,dobj->schemaName);
+							((DropFk*)dropDependent)->GenerateScript();
+							tabScr->GetFkScript()->AddDiffElement(dropDependent);
+							
+							// getting the index of the added obj
+							depIndex = tabScr->GetFkScript()->SearchObject(dobj->tableName,dobj->objName,DROPFK,dobj->schemaName); 
+							if(depIndex !=wxNOT_FOUND) // this would always be true, just checking
+								alterPk->iSetPkDepFkId(depIndex); // binding the dependent and non-dependent
+						}
+						else
+						{
+							; // do nothing as the columns would take care of the dependents
+						}
+					}
+				}
+			}
+			
+			((AlterPk*)alterPk)->setAlterCase(wxT("Overwrite")); // drop and add
+			((AlterPk*)alterPk)->GenerateScript();
+			tabScr->GetPkScript()->AddDiffElement(alterPk);
+			return true;
+		}
+	}
+	else 
+	{
+		/* if the drop pk is already in the list, this is a special case in because that shows
+		the column is being dropped along with the attached pk,but the new added pk has the same name
+		so no need to drop it again.
+		*/
+		AlterPk * alterPk = new AlterPk(this);
+		((AlterPk*)alterPk)->setAlterCase(wxT("Add"));
+		((AlterPk*)alterPk)->GenerateScript();
+		tabScr->GetPkScript()->AddDiffElement(alterPk);
+	}
+	return false;
+
+	//T	
+	wxString aS=srcPk->GetIndexType();
+	wxString aT=pgp->GetIndexType();
+
+	bool bS=srcPk->GetIsPrimary();
+	bool bT=pgp->GetIsPrimary();
+	
+	wxString cS=srcPk->GetColumns();
+	wxString cT=pgp->GetColumns();
+
+	
+	
+}
+////////////////////////////////////////////////////////////////
+void PkScript::GenerateScript()
+{
+}
+wxString PkScript::GenerateCreateScript(wxString tableName,wxString schemaName)
+{
+	wxString createPkScript;
+	// each table has a single pk entry
+	for(size_t i=0; i<this->pkDiffList.GetCount();i++)
+	{
+		PkElement *pkElem = this->pkDiffList.Item(i);
+		if(pkElem->GetMetaType() == CRTPK && 
+			pkElem->GetTableName() == tableName &&
+			pkElem->GetSchemaName() == schemaName)
+		{
+			createPkScript+=pkElem->GetScript();
+		}
+	}
+	return createPkScript;
+}
+wxString PkScript::GenerateAlterScript(wxString tableName,wxString schemaName,FkScript * fkScr,wxString ObjType)
+{
+	int SearchMetaType;
+	if(ObjType == wxT("DROP")) // fetch only drop elements
+		SearchMetaType = DROPPK;
+	else
+		SearchMetaType = ADDPK; 
+
+	wxString alterPkScript,tmp;
+	for(size_t i=0; i<this->pkDiffList.GetCount();i++)
+	{
+		PkElement *pkElem = this->pkDiffList.Item(i);
+		if((pkElem->GetMetaType() == SearchMetaType ||pkElem->GetMetaType() == ALTERPK) && 
+			pkElem->GetTableName() == tableName && 
+			pkElem->GetSchemaName() == schemaName)
+		{
+			if(pkElem->GetMetaType()==DROPPK &&
+				!pkElem->IsAlreadyApplied() ) 
+			{
+				DropPk * dropPk = (DropPk*)pkElem;
+				
+				if(dropPk->HasDepFk()) // col has fk dependent
+				{
+					for(size_t i=0; i< dropPk->GetDependentFkList().GetCount(); i++)
+					{
+						int fkId = dropPk->GetDependentFkList().Item(i);
+						// fetch the foriegn key from list
+						FkElement * fk = fkScr->GetFkList().Item(fkId);
+						if(!((DropFk*)fk)->IsAlreadyApplied())
+						{
+							tmp = ((DropFk*)fk)->GetScript(); // generating the drop script
+							if(tmp.length()>0)
+							alterPkScript+=tmp;
+						}
+						
+					}
+
+				}
+				// after dependency check add my script
+				tmp=pkElem->GetScript();
+				if(tmp.length()>0)
+				{
+					alterPkScript+=tmp;
+					alterPkScript+=wxT(";");
+				}
+			}
+			else if(pkElem->GetMetaType()==ADDPK)
+			{
+				tmp=pkElem->GetScript();
+				if(tmp.length()>0)
+				{
+					alterPkScript+=tmp;
+					alterPkScript+=wxT(";");
+				}
+			}
+			else if(pkElem->GetMetaType()==ALTERPK)
+			{
+				tmp=pkElem->GetScript();
+				if(tmp.length()>0)
+				{
+					alterPkScript+=tmp;
+					alterPkScript+=wxT(";");
+				}
+			}
+		}
+	}
+	return alterPkScript;
+}
+wxString PkScript::GenerateDropScript(wxString tableName,wxString schemaName,FkScript * fkScr)
+{
+	wxString dropPkScript,tmp;
+	for(size_t i=0; i<this->pkDiffList.GetCount();i++)
+	{
+		PkElement *pkElem = this->pkDiffList.Item(i);
+		if(pkElem->GetMetaType() == DROPPK && 
+			pkElem->GetTableName() == tableName && 
+			pkElem->GetSchemaName() == schemaName)
+		{
+			if(!pkElem->IsAlreadyApplied() ) 
+			{
+				DropPk * dropPk = (DropPk*)pkElem;
+				
+				if(dropPk->HasDepFk()) // col has fk dependent
+				{
+					for(size_t i=0; i< dropPk->GetDependentFkList().GetCount(); i++)
+					{
+						int fkId = dropPk->GetDependentFkList().Item(i);
+						// fetch the foriegn key from list
+						FkElement * fk = fkScr->GetFkList().Item(fkId);
+						if(!((DropFk*)fk)->IsAlreadyApplied())
+						{
+							tmp = ((DropFk*)fk)->GetScript(); // generating the drop script
+							if(tmp.length()>0)
+							dropPkScript+=tmp;
+						}
+					}
+				}
+				// after dependency check add my script
+				tmp=pkElem->GetScript();
+				if(tmp.length()>0)
+				{
+					dropPkScript+=tmp;
+					dropPkScript+=wxT(";");
+				}
+			}
+		}
+	}
+	return dropPkScript;
+}
+void PkScript::ApplyScript()
+{}
+void PkScript::AddDiffElement(PkElement * de)
+{
+	this->pkDiffList.Add(de);
+}
+int PkScript::SearchObject(wxString tableName,wxString objName,int metaType,wxString schemaName)
+{
+	if(schemaName.length()==0)
+		schemaName=wxT("public");
+
+	int index=wxNOT_FOUND;
+	for(size_t i=0; i<pkDiffList.GetCount();i++)
+	{
+		PkElement * de = pkDiffList.Item(i);
+		wxString schName = de->GetSchemaName();
+		wxString tabName = de->GetTableName();
+		
+		if(de->GetMetaType() == metaType)
+		{
+			if(metaType == DROPPK) // searching for dropped fk object
+			{
+				DropPk * dpk = (DropPk*)de;
+				wxString oName = dpk->GetPkName();
+				if( dpk->GetSchemaName() == schemaName && 
+					dpk->GetTableName() == tableName &&
+					dpk->GetPkName() == objName )
+				{
+					index = pkDiffList.Index(de);
+					break;
+				}
+			}
+		}
+	}
+	return index;
+}
diff --git a/pgadmin/sv/svRuleDiff.cpp b/pgadmin/sv/svRuleDiff.cpp
new file mode 100644
index 0000000..c09d869
--- /dev/null
+++ b/pgadmin/sv/svRuleDiff.cpp
@@ -0,0 +1,110 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svRuleDiff.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svRuleDiff.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+#include "sv/svRuleDiff.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svDropRule.h"
+
+bool RuleDiff::GenStructuralDiff(DiffObject * trgR,ctlTree * src, ctlTree * trg,wxTreeItemId dummyId,RuleScript *ruleScr)
+{
+	RuleDiff * trgRule = (RuleDiff*)trgR;
+	pgRule *pgr = trgRule->GetRule();
+	pgRule * srcRule = (pgRule*)this->GetObject();
+
+	if(srcRule->GetCondition()!=pgr->GetCondition())
+	{
+		// UI changes
+		////////////////////////////////////
+		trg->SetItemImage(pgr->GetId(),svImages.IMG_RULE_CHG);
+		wxTreeItemId id = trg->GetItemParent(pgr->GetId());
+		trg->SetItemImage(id,svImages.IMG_RULES_CHG);
+		/////////////////////////////////////
+		return true;
+	}
+	return false;
+}
+////////////////////////////////////////////////////////////////////////
+wxString RuleScript::GenerateCreateScript(wxString viewName,wxString schemaName)
+{
+	wxString createRuleScript;
+	for(size_t i=0; i<this->ruleDiffList.GetCount();i++)
+	{
+		RuleElement *ruleElem = this->ruleDiffList.Item(i);
+		if(ruleElem->GetMetaType() == CRTFK && 
+			ruleElem->GetViewName() == viewName &&
+			ruleElem->GetSchemaName() == schemaName)
+		{
+			createRuleScript+=ruleElem->GetScript();
+			if(createRuleScript.length()>0)
+				createRuleScript+=wxT(";");
+		}
+	}
+	return createRuleScript;
+}
+wxString RuleScript::GenerateDropScript(wxString viewName,wxString schemaName)
+{
+	wxString dropRuleScript,tmp;
+	for(size_t i=0; i<this->ruleDiffList.GetCount();i++)
+	{
+		RuleElement *ruleElem = this->ruleDiffList.Item(i);
+		if(ruleElem->GetMetaType()==DROPRULE && 
+			ruleElem->GetViewName() == viewName && 
+			ruleElem->GetSchemaName() == schemaName)
+		{
+			if(!ruleElem->IsAlreadyApplied())
+			{
+				tmp=ruleElem->GetScript();
+				if(tmp.length()>0)
+				{
+					dropRuleScript+=tmp;
+					dropRuleScript+=wxT(";");
+				}
+			}
+		}
+	}
+	return dropRuleScript;
+}
+
+void RuleScript::AddDiffElement(RuleElement * de)
+{
+	this->ruleDiffList.Add(de);
+}
+int RuleScript::SearchObject(wxString viewName,wxString objName,int metaType,wxString schemaName)
+{
+	if(schemaName.length()==0)
+		schemaName=wxT("public");
+
+	int index=wxNOT_FOUND;
+	for(size_t i=0; i<ruleDiffList.GetCount();i++)
+	{
+		RuleElement * de = ruleDiffList.Item(i);
+		wxString schName = de->GetSchemaName();
+		wxString tabName = de->GetViewName();
+		
+		if(de->GetMetaType() == metaType)
+		{
+			if(metaType == DROPRULE) // searching for dropped fk object
+			{
+				DropRule * dr = (DropRule*)de;
+				wxString oName = dr->GetRuleName();
+				if( dr->GetSchemaName() == schemaName && 
+					dr->GetViewName() == viewName &&
+					dr->GetRuleName() == objName )
+				{
+					index = ruleDiffList.Index(de);
+					break;
+				}
+			}
+		}
+	}
+	return index;
+}
diff --git a/pgadmin/sv/svSchemaDiff.cpp b/pgadmin/sv/svSchemaDiff.cpp
new file mode 100644
index 0000000..220cadf
--- /dev/null
+++ b/pgadmin/sv/svSchemaDiff.cpp
@@ -0,0 +1,457 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svSchemaDiff.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svSchemaDiff.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+#include "sv/svSchemaDiff.h"
+#include "sv/svTableDiff.h"
+#include "sv/svViewDiff.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svDbDiff.h"
+#include "sv/svCreateTable.h"
+#include "sv/svAlterTable.h"
+#include "sv/svDropTable.h"
+#include "sv/svCreateView.h"
+#include "sv/svDropView.h"
+
+SchemaDiff::SchemaDiff(pgObject * schema):DiffObject(schema)
+{	
+	schemahandle = (pgSchema*)schema;	
+	schemaChangesExist=false;
+}
+void SchemaDiff::LoadDiffSystemObjects(wxTreeItemId schemaRoot,ctlTree * tree)
+{
+	wxTreeItemId tableRoot, viewRoot, tableList, viewList;
+	wxCookieType schRootCookie, tabListCookie , viewListCookie;
+	
+	if(tree->HasChildren(schemaRoot))
+	{
+		tableRoot = tree->GetFirstChild(schemaRoot,schRootCookie);
+		viewRoot = tree->GetNextSibling(tableRoot);
+		
+		// loading tables
+		tableList = tree->GetFirstChild(tableRoot,tabListCookie);
+		while(tableList)
+		{
+			pgObject * table = tree->GetObject(tableList);
+			wxString tabname = table->GetName();
+			TableDiff * dtable = new TableDiff(table);
+			this->objlist.Add(dtable); // adding tables
+			dtable->LoadDiffSystemObjects(table->GetId(),tree);
+			tableList = tree->GetNextChild(tableRoot,tabListCookie);
+		}	
+		// loading views
+		viewList = tree->GetFirstChild(viewRoot,viewListCookie);
+		while(viewList)
+		{
+			pgObject * view = tree->GetObject(viewList);
+			wxString viewname = view->GetName();
+			ViewDiff * dview = new ViewDiff(view);
+			this->objlist.Add(dview); // adding views
+			dview->LoadDiffSystemObjects(view->GetId(),tree);
+			viewList = tree->GetNextChild(viewRoot,viewListCookie);
+		}
+	}
+}
+bool SchemaDiff::GenStructuralDiff(DiffObject * trgSch,ctlTree * src, ctlTree * trg,wxTreeItemId dummySchemaId,SchemaScript *schScr)
+{
+	SchemaDiff * trgSchema = (SchemaDiff *)trgSch;
+	
+	// append once - when to add/remove the whole subtree
+	if(!trgSchema && !trg->HasChildren(dummySchemaId))
+	{
+		wxTreeItemId dummyTablesId = NULL;
+		wxTreeItemId dummyViewsId = NULL;
+
+		dummyTablesId = trg->AppendItem(dummySchemaId,wxT("Tables (0)"),svImages.IMG_TABLES,-1,NULL);
+		this->SetDiffType(PGM_TABLE);
+		GenStrTableDiff(trgSch,src,trg,dummyTablesId,schScr);
+
+		dummyViewsId = trg->AppendItem(dummySchemaId,wxT("Views (0)"),svImages.IMG_VIEWS,-1,NULL);
+		this->SetDiffType(PGM_VIEW);
+		GenStrViewDiff(trgSch,src,trg,dummyViewsId,schScr);
+	}
+	// when both source & target is found
+	if(this->GetDiffType() == PGM_TABLE)
+	{
+		GenStrTableDiff(trgSch,src,trg,NULL,schScr);
+	}
+	else if(this->GetDiffType() == PGM_VIEW)
+	{
+		GenStrViewDiff(trgSch,src,trg,NULL,schScr);
+	}
+
+	// searching for the schema objects not present in source
+	// assuming that the target is not empty
+	// used to expand the tree
+	/*if(!(trgSchema->GetSchemaObjList().empty()))
+	{
+		if(this->GetDiffType()==PGM_TABLE){
+			TableDiff *pgT = (TableDiff *)(trgSchema->GetSchemaObjList()).Item(0);  
+			trg->Expand(trg->GetItemParent(pgT->GetTable()->GetId()));
+		}
+		if(this->GetDiffType()==PGM_TABLE){
+			ViewDiff *pgV = (ViewDiff *)(trgSchema->GetSchemaObjList()).Item(0);  
+			trg->Expand(trg->GetItemParent(pgV->GetView()->GetId()));
+		}
+	}*/
+	return this->schemaChangesExist;
+}
+void SchemaDiff::GenStrTableDiff(DiffObject *trgSch,ctlTree * src,ctlTree *trg,wxTreeItemId dummyTablesId,SchemaScript *schScr)
+{
+	SchemaDiff * trgSchema = (SchemaDiff *)trgSch;
+	for(size_t i=0; i < (this->objlist.GetCount()) ; i++)
+	{
+		DiffObject *srcSchemaObj = (DiffObject *)(this->objlist.Item(i)); 
+
+		if(this->GetDiffType() == srcSchemaObj->GetObject()->GetMetaType() &&
+			this->GetDiffType() == PGM_TABLE)
+		{
+			TableDiff *srcTable = (TableDiff *)srcSchemaObj; 
+			wxString tabName  = srcTable->GetTable()->GetName();
+			
+			if(!trgSchema ||  // trgSchema would be null when schema is not present at the target 
+				!trgSchema->IsPresent(tabName,PGM_TABLE)) // if schema is present but schema objects are missing in target
+			{ 
+				TableElement* crtTable = new CreateTable(srcTable); 
+				((CreateTable*)crtTable)->GenerateScript(); // this would generate the script for Table difference
+				schScr->GetTableScriptHandle()->AddDiffElement(crtTable);
+
+				pgTable* pgt = srcTable->GetTable();
+				schemaChangesExist=true;
+				
+				//////////////////////////////////////////////////////////////////////////////////////////////
+				// performing UI changes, 
+
+				// showing its missing in target
+				wxTreeItemId tablesId = dummyTablesId;
+				wxTreeItemId tableId;
+				if(!trgSchema)  // add the whole schema sub tree
+				{
+					tableId = trg->AppendItem(tablesId,tabName,svImages.IMG_TABLE_PRES,-1,NULL);
+					trg->SetItemImage(tablesId,svImages.IMG_TABLES_CHG);  
+					trg->SortChildren(tablesId);
+				}
+				else
+				{
+					wxTreeItemId schId = trgSchema->GetObject()->GetId();
+					wxCookieType cookie;
+					tablesId = trg->GetFirstChild(schId,cookie);
+					tableId = trg->AppendItem(tablesId,tabName,svImages.IMG_TABLE_PRES,-1,NULL);
+					trg->SetItemImage(tablesId,svImages.IMG_TABLES_CHG);  
+					trg->SortChildren(tablesId);
+				}
+				srcTable->GenStructuralDiff(NULL,src,trg,tableId,schScr->GetTableScriptHandle(),schScr->GetViewScriptHandle());
+				////////////////////////////////////////////////////////////////////////////////////////////
+			}
+			else // table got matched
+			{
+				TableElement* alterTable = new AlterTable(srcTable); 
+				((AlterTable*)alterTable)->GenerateScript(); // this would generate the script for Table difference
+				schScr->GetTableScriptHandle()->AddDiffElement(alterTable);
+				TableDiff * trgTable = (TableDiff*)trgSchema->FindObj(tabName,PGM_TABLE);
+
+				// UI changes
+				bool tableChangesExist;
+				tableChangesExist = srcTable->GenStructuralDiff(trgTable,src,trg,NULL,schScr->GetTableScriptHandle(),schScr->GetViewScriptHandle());
+				if(tableChangesExist)
+				{
+					schemaChangesExist=true;
+					
+					wxTreeItemId tablesId;
+					wxCookieType cookie;
+
+					// changing tables collection icon
+					wxTreeItemId schId = trgSchema->GetObject()->GetId();
+					tablesId = trg->GetFirstChild(schId,cookie);
+					trg->SetItemImage(tablesId,svImages.IMG_TABLES_CHG);
+					// changing table object icon
+					wxTreeItemId tableId = trgTable->GetObject()->GetId();
+					trg->SetItemImage(tableId,svImages.IMG_TABLE_CHG);  
+					tableChangesExist=false; 
+				}
+			}
+		}
+	}
+	if(trgSchema)
+	{
+		for(size_t i=0; i < (trgSchema->GetSchemaObjList().GetCount()) ; i++)
+		{
+			DiffObject *trgSchemaObj = (DiffObject *)(trgSchema->GetSchemaObjList()).Item(i); 
+			
+			if(this->GetDiffType() == trgSchemaObj->GetObject()->GetMetaType() &&
+				this->GetDiffType() == PGM_TABLE)
+			{
+				TableDiff *trgTable = (TableDiff *)trgSchemaObj; 
+				wxString tabName  = trgTable->GetTable()->GetName();
+				if(!this->IsPresent(tabName,PGM_TABLE)) 
+				{
+					TableElement* dropTable = new DropTable(trgTable); 
+					((DropTable*)dropTable)->GenerateScript(); // this would generate the script for Table difference
+					schScr->GetTableScriptHandle()->AddDiffElement(dropTable);
+					schemaChangesExist=true;
+
+					pgTable* pgt = trgTable->GetTable();
+					// performing UI changes
+
+					// showing present elements @ target
+					////////////////////////////////////
+					trg->SetItemImage(pgt->GetId(),svImages.IMG_TABLE_MISS);
+					wxTreeItemId id = trg->GetItemParent(pgt->GetId());
+					trg->SetItemImage(id,svImages.IMG_TABLES_CHG);
+					/////////////////////////////////////
+
+					// function to drop the tables
+					TableDiff::DropTableObject(trgTable,src,trg,schScr->GetTableScriptHandle(),schScr->GetViewScriptHandle());
+				}
+			}
+		}
+	}
+}
+void SchemaDiff::GenStrViewDiff(DiffObject *trgSch,ctlTree * src,ctlTree *trg,wxTreeItemId dummyViewsId,SchemaScript *schScr)
+{
+	SchemaDiff * trgSchema = (SchemaDiff *)trgSch;
+	for(size_t i=0; i < (this->objlist.GetCount()) ; i++)
+	{
+		DiffObject *srcSchemaObj = (DiffObject *)(this->objlist.Item(i)); 
+
+		if(this->GetDiffType() == srcSchemaObj->GetObject()->GetMetaType() &&
+			this->GetDiffType() == PGM_VIEW)
+		{
+			// code for views
+			ViewDiff *srcView = (ViewDiff *)(this->objlist.Item(i)); 
+			wxString viewName  = srcView->GetView()->GetName();
+			
+			if(!trgSchema ||  // trgSchema would be null when it is not present at the target end 
+				!trgSchema->IsPresent(viewName,this->GetDiffType())) // if missing in target
+			{ 
+				ViewElement* crtView = new CreateView(srcView); 
+				((CreateView*)crtView)->GenerateScript(); // this would generate the script for Table difference
+				schScr->GetViewScriptHandle()->AddDiffElement(crtView);
+				schemaChangesExist=true;
+				
+				pgView* pgv = srcView->GetView();
+				//////////////////////////////////////////////////////////////////////////////////////////////
+				// performing UI changes, 
+				wxTreeItemId viewsId = dummyViewsId;
+				wxTreeItemId viewId;
+				if(!trgSchema)  // add the whole schema sub tree
+				{
+					viewId = trg->AppendItem(viewsId,viewName,svImages.IMG_VIEW_PRES,-1,NULL);
+					trg->SortChildren(trg->GetItemParent(viewsId));
+				}
+				else 
+				{
+					wxTreeItemId schId = trgSchema->GetObject()->GetId();
+					wxCookieType cookie;
+					wxTreeItemId tablesId = trg->GetFirstChild(schId,cookie);
+					wxTreeItemId viewsId = trg->GetNextSibling(tablesId);
+					viewId = trg->AppendItem(viewsId,viewName,svImages.IMG_VIEW_PRES,-1,NULL);
+					trg->SetItemImage(viewsId,svImages.IMG_VIEWS_CHG);
+					trg->SortChildren(trg->GetItemParent(viewsId));
+				}
+				
+				////////////////////////////////////////////////////////////////////////////////////////////
+				srcView->GenStructuralDiff(NULL,src,trg,viewId,schScr->GetViewScriptHandle());
+			}
+			else // views got matched
+			{
+				ViewDiff * trgView = (ViewDiff*)trgSchema->FindObj(viewName,PGM_VIEW);
+				srcView->GenStructuralDiff(trgView,src,trg,NULL,schScr->GetViewScriptHandle());
+			}
+		}
+	}
+	if(trgSchema)
+	{
+		for(size_t i=0; i < (trgSchema->GetSchemaObjList().GetCount()) ; i++)
+		{
+			DiffObject *trgSchemaObj = (DiffObject *)(trgSchema->GetSchemaObjList()).Item(i); 
+			
+			if(this->GetDiffType() == trgSchemaObj->GetObject()->GetMetaType() &&
+				this->GetDiffType() == PGM_VIEW)
+			{
+				ViewDiff *trgView = (ViewDiff *)trgSchemaObj; 
+				wxString viewName  = trgView->GetView()->GetName();
+				if(!this->IsPresent(viewName,PGM_VIEW)) 
+				{ 
+					pgView* pgv = trgView->GetView();
+
+					int index = schScr->GetViewScriptHandle()->SearchObject(viewName,DROPVIEW,pgv->GetSchema()->GetName());
+					if(index==wxNOT_FOUND)
+					{
+						ViewElement* dropView = new DropView(trgView); 
+						((DropView*)dropView)->GenerateScript(); // this would generate the script for Table difference
+						schScr->GetViewScriptHandle()->AddDiffElement(dropView);
+					}
+					
+					////////////////////////////////////
+					trg->SetItemImage(pgv->GetId(),svImages.IMG_VIEW_MISS);
+					wxTreeItemId id = trg->GetItemParent(pgv->GetId());
+					trg->SetItemImage(id,svImages.IMG_VIEWS_CHG);
+					/////////////////////////////////////
+
+					// function to drop the view
+					ViewDiff::DropViewObject(trgView,src,trg,schScr->GetViewScriptHandle());
+				}
+			}
+		}
+	}
+}
+bool SchemaDiff::IsPresent(wxString objname,int meta_type)
+{
+	
+	bool found = false;
+	DiffObject * diffObj;
+	
+	for(size_t i =0 ; i< (this->objlist.GetCount()) ; i++)
+	{
+	    diffObj = (this->objlist.Item(i));
+
+		if(diffObj->GetObject()->GetMetaType() == meta_type)
+		{
+			if(diffObj->GetObject()->GetName() == objname) 
+			{ 
+				found = true;
+				break;
+			}
+		}
+	}
+	return found;
+}
+DiffObject *SchemaDiff::FindObj(wxString objname,int meta_type)
+{
+
+	bool found = false;
+	DiffObject * diffObj;
+	
+	for(size_t i =0 ; i< (this->objlist.GetCount()) ; i++)
+	{
+	    diffObj = (this->objlist.Item(i));
+ 
+		if(diffObj->GetObject()->GetMetaType() == meta_type)
+		{
+			wxString t = diffObj->GetObject()->GetName();
+			if(diffObj->GetObject()->GetName() == objname) 
+			{ 
+				return diffObj;
+			}
+		}
+	}
+	return 0;
+}
+void SchemaDiff::DropSchemaObject(DiffObject * trgSch,ctlTree * src, ctlTree * trg,SchemaScript *schScr)
+{
+	SchemaDiff * trgSchema = (SchemaDiff *)trgSch;
+
+	// dropping all tables
+	for(size_t i=0; i < (trgSchema->GetSchemaObjList().GetCount()) ; i++)
+	{
+		DiffObject *trgSchemaObj = (DiffObject *)(trgSchema->GetSchemaObjList()).Item(i); 
+		
+		if(trgSchemaObj->GetObject()->GetMetaType()==PGM_TABLE )
+		{
+			TableDiff *trgTable = (TableDiff *)trgSchemaObj; 
+			wxString tabName  = trgTable->GetTable()->GetName();
+			pgTable* pgt = trgTable->GetTable();
+
+			TableElement* dropTable = new DropTable(trgTable); 
+			((DropTable*)dropTable)->GenerateScript(); // this would generate the script for Table difference
+			schScr->GetTableScriptHandle()->AddDiffElement(dropTable);
+				
+			// performing UI changes
+			// showing present elements @ target
+			////////////////////////////////////
+			trg->SetItemImage(pgt->GetId(),svImages.IMG_TABLE_MISS);
+			wxTreeItemId id = trg->GetItemParent(pgt->GetId());
+			trg->SetItemImage(id,svImages.IMG_TABLES_CHG);
+			/////////////////////////////////////
+
+			// function to drop the tables
+			TableDiff::DropTableObject(trgTable,src,trg,schScr->GetTableScriptHandle(),schScr->GetViewScriptHandle());
+		}
+	}
+	// dropping all views
+
+	for(size_t i=0; i < (trgSchema->GetSchemaObjList().GetCount()) ; i++)
+	{
+		DiffObject *trgSchemaObj = (DiffObject *)(trgSchema->GetSchemaObjList()).Item(i); 
+		
+		if(trgSchemaObj->GetObject()->GetMetaType() == PGM_VIEW)
+		{
+			ViewDiff *trgView = (ViewDiff *)trgSchemaObj; 
+			wxString viewName  = trgView->GetView()->GetName();
+			
+			pgView* pgv = trgView->GetView();
+			
+
+			int index = schScr->GetViewScriptHandle()->SearchObject(viewName,DROPVIEW,pgv->GetSchema()->GetName());
+			if(index==wxNOT_FOUND)
+			{
+				ViewElement* dropView = new DropView(trgView); 
+				((DropTable*)dropView)->GenerateScript(); // this would generate the script for Table difference
+				schScr->GetViewScriptHandle()->AddDiffElement(dropView);
+			}
+
+			// performing UI changes
+			////////////////////////////////////
+			trg->SetItemImage(pgv->GetId(),svImages.IMG_VIEW_MISS);
+			wxTreeItemId id = trg->GetItemParent(pgv->GetId());
+			trg->SetItemImage(id,svImages.IMG_VIEWS_CHG);
+			/////////////////////////////////////
+		}
+	}
+}
+/////////////////////////////////////////////////////////////////////////////////////////////////////////
+void SchemaScript::Initialize()
+{
+	// order of instantiation is important
+	viewScript = new ViewScript();
+	viewScript->Initialize();
+
+	tableScript = new TableScript();
+	tableScript->Initialize(viewScript);
+}
+void SchemaScript::GenerateScript()
+{
+}
+wxString SchemaScript::GenerateCreateScript(wxString schemaName)
+{
+	wxString createSchemaScript;
+	createSchemaScript = this->tableScript->GenerateCreateScript(schemaName);
+	createSchemaScript += this->viewScript->GenerateCreateScript(schemaName);
+
+	return createSchemaScript;
+}
+
+wxString SchemaScript::GenerateAlterScript(wxString schemaName)
+{
+	// order of exec is strict
+	wxString alterSchemaScript;
+	alterSchemaScript += this->viewScript->GenerateDropScript(schemaName);
+	alterSchemaScript += this->tableScript->GenerateAlterScript(schemaName);
+	alterSchemaScript += this->viewScript->GenerateCreateScript(schemaName);
+	
+	return alterSchemaScript;
+}
+wxString SchemaScript::GenerateFkScripts(wxString schemaName)
+{
+	wxString fkScript;
+	fkScript += this->tableScript->GenerateAlterFkScripts(schemaName);
+	fkScript += this->tableScript->GenerateCreateFkScripts(schemaName);
+	return fkScript;
+}
+wxString SchemaScript::GenerateDropScript(wxString schemaName)
+{
+	wxString dropSchemaScript;
+	dropSchemaScript = this->tableScript->GenerateDropScript(schemaName);
+	dropSchemaScript += this->viewScript->GenerateDropScript(schemaName);
+	
+	return dropSchemaScript;
+}
diff --git a/pgadmin/sv/svTableDiff.cpp b/pgadmin/sv/svTableDiff.cpp
new file mode 100644
index 0000000..7bf55ce
--- /dev/null
+++ b/pgadmin/sv/svTableDiff.cpp
@@ -0,0 +1,1955 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svTableDiff.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svTableDiff.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "sv/svTableDiff.h"
+#include "sv/svColumnDiff.h"
+#include "sv/svPKDiff.h"
+#include "sv/svFKDiff.h"
+#include "sv/svUniqueDiff.h"
+
+#include "sv/svIndexDiff.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svDiffElement.h"
+#include "sv/svDbDiff.h"
+#include "sv/svSchemaDiff.h"
+#include "sv/svCreatePk.h"
+#include "sv/svCreateFk.h"
+#include "sv/svCreateIndex.h"
+#include "sv/svCreateColumn.h"
+#include "sv/svCreateUnique.h"
+
+#include "sv/svAddPk.h"
+#include "sv/svAddFk.h"
+#include "sv/svAddIndex.h"
+#include "sv/svAddColumn.h"
+#include "sv/svAlterColumn.h"
+#include "sv/svAddUnique.h"
+#include "sv/svDropUnique.h"
+#include "sv/svDropFk.h"
+#include "sv/svDropPk.h"
+#include "sv/svDropColumn.h"
+#include "sv/svDropIndex.h"
+#include "sv/svDropView.h"
+
+
+
+
+
+TableDiff::TableDiff(pgObject * table):DiffObject(table)
+{
+	tablehandle = (pgTable *)table;
+	//tablescript = scriptsys.GetTableScript();
+	this->primaryKey = NULL;
+	this->tableChangesExist=false;
+}
+
+void TableDiff::LoadDiffSystemObjects(wxTreeItemId tableRoot, ctlTree * tree)
+{
+	wxTreeItemId columnRoot, indexRoot, constraintRoot, columnList,constraintList,indexList;
+	wxCookieType tabRootCookie, colListCookie, constRootCookie, indRootCookie,constListCookie,indListCookie;
+
+	pgObject * data = tree->GetObject(tableRoot);
+	if(tree->HasChildren(tableRoot))
+	{
+		columnRoot = tree->GetFirstChild(tableRoot,tabRootCookie);
+		constraintRoot = tree->GetNextSibling(columnRoot);
+		indexRoot = tree->GetNextSibling(constraintRoot);
+
+		// checking for column
+		if(tree->HasChildren(columnRoot))
+		{
+			columnList = tree->GetFirstChild(columnRoot,colListCookie);
+			while(columnList)
+			{
+				pgObject * column = tree->GetObject(columnList);
+				ColumnDiff * dcol = new ColumnDiff(column);
+				this->colObjList.Add(dcol);	// adding column to list
+				columnList = tree->GetNextChild(columnRoot,colListCookie);
+			}
+		}
+		// checking for index
+		if(tree->HasChildren(indexRoot))
+		{
+			indexList = tree->GetFirstChild(indexRoot,indListCookie);
+			while(indexList)
+			{
+				pgObject *index = tree->GetObject(indexList);
+				IndexDiff * dind = new IndexDiff(index);
+				this->indObjList.Add(dind); // adding index to list
+				indexList = tree->GetNextChild(indexRoot,indListCookie);
+			}
+		}
+		// checking for constraints
+		if(tree->HasChildren(constraintRoot))
+		{ 
+			constraintList = tree->GetFirstChild(constraintRoot,constListCookie);
+			DiffObject *dobj;
+			while(constraintList)
+			{
+				pgObject * constraint = tree->GetObject(constraintList);
+				if(constraint->GetMetaType() == PGM_PRIMARYKEY)
+				{
+					wxString name = constraint->GetName();
+					wxString name1 = constraint->GetTable()->GetName();
+					dobj = new PkDiff(constraint); 
+					this->SetPk(dobj);
+				}
+				else if(constraint->GetMetaType() == PGM_FOREIGNKEY)
+				{
+					dobj = new FkDiff(constraint); 
+					this->fkObjList.Add(dobj);
+				}
+				else if(constraint->GetMetaType() == PGM_UNIQUE)
+				{
+					dobj = new UniqueDiff(constraint);
+					this->uniqueObjList.Add(dobj);
+				}
+				constraintList = tree->GetNextChild(constraintRoot,constListCookie);
+			}
+		}
+	}
+}
+bool TableDiff::GenStructuralDiff(DiffObject * trgTab,ctlTree * src, ctlTree * trg,wxTreeItemId dummyTableId,TableScript * tabScr,ViewScript *viewScr)
+{
+	wxTreeItemId dummyColumnsId=NULL;
+	wxTreeItemId dummyIndexesId=NULL;
+	wxTreeItemId dummyConstraintsId=NULL;
+
+	if(!trgTab && !trg->HasChildren(dummyTableId))  // add the whole schema sub tree
+	{
+		// showing columns root
+		trg->AppendItem(dummyTableId,wxT("Columns (0)"),svImages.IMG_COLUMNS,-1,NULL);
+		// showing constraints root
+		
+		trg->AppendItem(dummyTableId,wxT("Constraints (0)"),svImages.IMG_CONSTRAINTS,-1,NULL);
+		// showing indexes root
+		trg->AppendItem(dummyTableId,wxT("Indexes (0)"),svImages.IMG_INDEXES,-1,NULL);
+	}
+
+	wxCookieType cookie;
+	if(!trgTab)
+	{
+		dummyColumnsId = trg->GetFirstChild(dummyTableId,cookie);
+		dummyConstraintsId = trg->GetNextChild(dummyTableId,cookie);
+		dummyIndexesId = trg->GetNextChild(dummyTableId,cookie);
+	}
+	
+
+	GenStrColumnDiff(trgTab,src,trg,dummyColumnsId,tabScr,viewScr);
+	GenStrIndexDiff(trgTab,src,trg,dummyIndexesId,tabScr);
+	GenStrFkDiff(trgTab,src,trg,dummyConstraintsId,tabScr);
+	GenStrPkDiff(trgTab,src,trg,dummyConstraintsId,tabScr);
+	GenStrUniqueDiff(trgTab,src,trg,dummyConstraintsId,tabScr);
+
+	return this->tableChangesExist;
+}
+bool TableDiff::IsColPresent(wxString objname)
+{
+	
+	bool found = false;
+	ColumnDiff * col;
+	
+	for(size_t i =0 ; i < (this->colObjList.GetCount()) ; i++)
+	{
+	    col = (ColumnDiff*)(this->colObjList.Item(i));
+
+		if(col->GetObject()->GetName() == objname) 
+		{ 
+			found = true;
+			break;
+		}
+	}
+	return found;
+}
+bool TableDiff::IsIndexPresent(wxString objname)
+{
+	
+	bool found = false;
+	IndexDiff * ind;
+	
+	for(size_t i =0 ; i < (this->indObjList.GetCount()) ; i++)
+	{
+	    ind = (IndexDiff*)(this->indObjList.Item(i));
+
+		if(ind->GetObject()->GetName() == objname) 
+		{ 
+			found = true;
+			break;
+		}
+	
+	}
+	return found;
+}
+bool TableDiff::IsFkPresent(wxString objname)
+{
+	
+
+	bool found = false;
+	FkDiff * fk;
+	
+	for(size_t i =0 ; i< (this->fkObjList.GetCount()) ; i++)
+	{
+	    fk = (FkDiff*)(this->fkObjList.Item(i));
+
+		if(fk->GetObject()->GetName() == objname) 
+		{ 
+			found = true;
+			break;
+		}
+	
+	}
+	return found;
+}
+bool TableDiff::IsPkPresent(wxString objname)
+{
+	PkDiff * tmp;
+	tmp = this->GetPk();
+	if(tmp)// if pk is set at target 
+	{
+		if(this->GetPk()->GetPk()->GetName()==objname) 
+			return true;
+	}
+	return false;
+}
+DiffObject *TableDiff::FindUniqueObj(wxString objname)
+{
+
+	bool found = false;
+	UniqueDiff * ud;
+	
+	for(size_t i =0 ; i< (this->uniqueObjList.GetCount()) ; i++)
+	{
+	    ud = (UniqueDiff*)(this->uniqueObjList.Item(i));
+		if(ud->GetObject()->GetName() == objname) 
+		{ 
+			return ud;
+		}
+	}
+	return 0;
+}
+DiffObject *TableDiff::FindColObj(wxString objname)
+{
+
+	bool found = false;
+	ColumnDiff * col;
+	
+	for(size_t i =0 ; i< (this->colObjList.GetCount()) ; i++)
+	{
+	    col = (ColumnDiff*)(this->colObjList.Item(i));
+
+		if(col->GetObject()->GetName() == objname) 
+		{ 
+			return col;
+		}
+	}
+	return 0;
+}
+DiffObject *TableDiff::FindIndexObj(wxString objname)
+{
+
+	bool found = false;
+	IndexDiff * ind;
+	
+	for(size_t i =0 ; i< (this->indObjList.GetCount()) ; i++)
+	{
+	    ind = (IndexDiff*)(this->indObjList.Item(i));
+
+		if(ind->GetObject()->GetName() == objname) 
+		{ 
+			return ind;
+		}
+	}
+	return 0;
+}
+DiffObject *TableDiff::FindFkObj(wxString objname)
+{
+
+	bool found = false;
+	FkDiff * fk;
+	
+	for(size_t i = 0 ; i < (this->fkObjList.GetCount()) ; i++)
+	{
+	    fk = (FkDiff*)(this->fkObjList.Item(i));
+
+		if(fk->GetObject()->GetName() == objname) 
+		{ 
+			return fk;
+		}
+	}
+	return 0;
+}
+
+void TableDiff::GenStrPkDiff(DiffObject * trgTab,ctlTree* src, ctlTree * trg,wxTreeItemId dummyConstraintsId,TableScript * tabScr)
+{
+	
+	TableDiff * trgTable = (TableDiff *)trgTab;
+	PkDiff *srcPk = this->GetPk();
+	if(srcPk)
+	{
+		wxString pkName  = srcPk->GetPk()->GetName();
+		
+		if(!trgTable ||  // trgTable would be null when table is not present at the target 
+			!trgTable->IsPkPresent(pkName)) // if schema is present but schema objects are missing in target
+		{ 
+			pgPrimaryKey *pgp = srcPk->GetPk();
+			this->tableChangesExist=true;
+			
+			wxTreeItemId constraintsId;
+			constraintsId = dummyConstraintsId;
+			
+			// showing its missing in target and had to be added
+			if(!trgTable)  // adding the whole schema sub tree
+			{
+				// CREATE table case
+				PkElement *crtPk = new CreatePk(srcPk);
+				((CreatePk*)crtPk)->GenerateScript(); 
+				tabScr->GetPkScript()->AddDiffElement(crtPk);
+				
+			
+				// UI changes
+				trg->AppendItem(constraintsId,pkName,svImages.IMG_PK_PRES,-1,NULL);
+				trg->SetItemImage(constraintsId,svImages.IMG_CONSTRAINTS_CHG);
+				trg->SortChildren(constraintsId);
+			}
+			else
+			{
+				// ALTER table case
+				PkElement *addPk = new AddPk(srcPk); 
+				((AddPk*)addPk)->GenerateScript(); 
+				tabScr->GetPkScript()->AddDiffElement(addPk);
+				
+				// UI changes
+				wxTreeItemId tableId = trgTable->GetObject()->GetId();
+				wxCookieType cookie;
+				wxTreeItemId columnsId = trg->GetFirstChild(tableId,cookie);
+				wxTreeItemId constraintsId = trg->GetNextSibling(columnsId);
+				
+
+				trg->AppendItem(constraintsId,pkName,svImages.IMG_PK_PRES,-1,NULL);
+				trg->SetItemImage(constraintsId,svImages.IMG_CONSTRAINTS_CHG);
+				trg->SortChildren(constraintsId);
+				
+			}
+			////////////////////////////////////////////////////////////////////////////////////////////
+		}
+		else // primary exist at both end
+		{
+			//
+			bool pkChangesExist=false;
+			PkDiff * trgPk = trgTable->GetPk();
+			pkChangesExist = srcPk->GenStructuralDiff(trgPk,src,trg,NULL,tabScr);
+			
+			if(pkChangesExist)
+			{
+				this->tableChangesExist=true;
+				pkChangesExist=false;
+			}
+		}
+	}
+	// searching for the pk objects not present in source
+	if(trgTable)
+	{
+		PkDiff *trgPk = trgTable->GetPk(); 
+		if(trgPk)
+		{
+			wxString pkName  = trgPk->GetPk()->GetName();
+			if(!this->IsPkPresent(pkName)) 
+			{ 
+				pgPrimaryKey *pgp = trgPk->GetPk();
+				this->tableChangesExist=true;
+
+				// showing present elements @ target
+				////////////////////////////////////
+				trg->SetItemImage(pgp->GetId(),svImages.IMG_PK_MISS);
+				wxTreeItemId id = trg->GetItemParent(pgp->GetId());
+				trg->SetItemImage(id,svImages.IMG_CONSTRAINTS_CHG);
+				/////////////////////////////////////
+
+				DropPk * dropPk = new DropPk(trgPk);
+				////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+				// checking dependency and adding required dependent obj to drop this obj
+				DependentObjArray depList;
+				wxString where;
+				TableDiff::GetDependents(pgp,depList,where);
+			
+				int obj = tabScr->GetPkScript()->SearchObject(pgp->GetTable()->GetName(),pgp->GetName(),DROPPK,pgp->GetSchema()->GetName());
+				if(obj==wxNOT_FOUND) // if the drop index is not already entered by drop column
+				{
+					if(!depList.IsEmpty())
+						BindDropPkDependents(tabScr,depList,dropPk,pgp);
+						
+					((DropPk*)dropPk)->GenerateScript();
+					tabScr->GetPkScript()->AddDiffElement(dropPk);
+				}
+				else
+				{
+					;// do nothing
+				}
+				////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+			}
+		}
+	}
+}
+void TableDiff::GenStrFkDiff(DiffObject * trgTab,ctlTree* src, ctlTree * trg,wxTreeItemId dummyConstraintsId,TableScript * tabScr)
+{
+	TableDiff * trgTable = (TableDiff *)trgTab;
+	// searching for the schema objects not present in trg
+	for(size_t i=0; i < (this->fkObjList.GetCount()) ; i++)
+	{
+		FkDiff *srcFk = (FkDiff *)(this->fkObjList.Item(i)); 
+		wxString fkName  = srcFk->GetFk()->GetName();
+		
+		if(!trgTable ||  // trgTable would be null when table is not present at the target 
+			!trgTable->IsFkPresent(fkName)) // if schema is present but schema objects are missing in target
+		{ 
+			pgForeignKey *pgf = srcFk->GetFk();
+			this->tableChangesExist=true;
+			
+			// showing its missing in target
+			wxTreeItemId constraintsId;
+			constraintsId = dummyConstraintsId;
+			
+			// showing its missing in target and had to be added
+			if(!trgTable)  // adding the whole schema sub tree
+			{
+				// CREATE table case
+				FkElement* crtFk = new CreateFk(srcFk); 
+				((CreateFk*)crtFk)->GenerateScript(); // this would generate the script for Table difference
+				tabScr->GetFkScript()->AddDiffElement(crtFk);
+
+				// UI changes
+				trg->AppendItem(constraintsId,fkName,svImages.IMG_FK_PRES,-1,NULL);
+				trg->SetItemImage(constraintsId,svImages.IMG_CONSTRAINTS_CHG);
+				trg->SortChildren(constraintsId);
+			}
+			else
+			{
+				//ALTER table case
+				FkElement* addFk = new AddFk(srcFk); 
+				((AddFk*)addFk)->GenerateScript(); // this would generate the script for Table difference
+				tabScr->GetFkScript()->AddDiffElement(addFk);
+
+				// UI changes
+				wxTreeItemId tableId = trgTable->GetObject()->GetId();
+				wxCookieType cookie;
+				wxTreeItemId columnsId = trg->GetFirstChild(tableId,cookie);
+				wxTreeItemId constraintsId = trg->GetNextSibling(columnsId);
+				
+				trg->AppendItem(constraintsId,fkName,svImages.IMG_FK_PRES,-1,NULL);
+				trg->SetItemImage(constraintsId,svImages.IMG_CONSTRAINTS_CHG);
+				trg->SortChildren(constraintsId);
+			}
+			////////////////////////////////////////////////////////////////////////////////////////////
+		}
+		else // fk got matched
+		{
+			bool fkChangesExist=false;
+			FkDiff * trgFk = (FkDiff*)trgTable->FindFkObj(fkName);
+			fkChangesExist = srcFk->GenStructuralDiff(trgFk,src,trg,NULL,tabScr->GetFkScript());
+			if(fkChangesExist)
+			{
+				this->tableChangesExist=true;
+				fkChangesExist=false;
+			}
+		}
+	}
+	
+	if(trgTable)
+	{
+		for(size_t i=0; i < (trgTable->GetFkObjList().GetCount()) ; i++)
+		{
+			FkDiff *trgFk = (FkDiff *)(trgTable->GetFkObjList()).Item(i); 
+	
+			wxString fkName  = trgFk->GetFk()->GetName();
+			if(!this->IsFkPresent(fkName)) 
+			{ 
+				pgForeignKey *pgf = trgFk->GetFk();
+				this->tableChangesExist=true;
+
+				int obj = tabScr->GetFkScript()->SearchObject(pgf->GetTable()->GetName(),pgf->GetName(),DROPFK,pgf->GetSchema()->GetName());
+				if(obj==wxNOT_FOUND)
+				{
+					DropFk * dropFk = new DropFk(trgFk);
+					((DropFk*)dropFk)->GenerateScript();
+					tabScr->GetFkScript()->AddDiffElement(dropFk);
+				}
+
+				// performing UI changes
+				// showing present elements @ target
+				////////////////////////////////////
+				trg->SetItemImage(pgf->GetId(),svImages.IMG_FK_MISS);
+				wxTreeItemId id = trg->GetItemParent(pgf->GetId());
+				trg->SetItemImage(id,svImages.IMG_CONSTRAINTS_CHG);
+				/////////////////////////////////////
+			}
+		}
+	}
+}
+void TableDiff::GenStrIndexDiff(DiffObject * trgTab,ctlTree* src, ctlTree * trg,wxTreeItemId dummyIndexesId,TableScript * tabScr)
+{
+	TableDiff * trgTable = (TableDiff *)trgTab;
+	// searching for the schema objects not present in trg
+	for(size_t i=0; i < (this->indObjList.GetCount()) ; i++)
+	{
+		IndexDiff *srcIndex = (IndexDiff *)(this->indObjList.Item(i)); 
+		wxString indName  = srcIndex->GetIndex()->GetName();
+		
+		if(!trgTable ||  // trgTable would be null when table is not present at the target 
+			!trgTable->IsIndexPresent(indName)) // if schema is present but schema objects are missing in target
+		{ 
+			pgIndex* pgi = srcIndex->GetIndex();
+			this->tableChangesExist=true;
+			
+			//////////////////////////////////////////////////////////////////////////////////////////////
+			// performing UI changes, 
+
+			// showing its missing in target
+
+			wxTreeItemId indexesId;
+			indexesId = dummyIndexesId;
+			if(!trgTable)  // adding the whole schema sub tree
+			{
+				// CREATE table case
+				IndexElement* crtIndex = new CreateIndex(srcIndex); 
+				((CreateIndex*)crtIndex)->GenerateScript(); // this would generate the script for Table difference
+				tabScr->GetIndexScript()->AddDiffElement(crtIndex);
+
+				// UI changes
+				trg->AppendItem(indexesId,indName,svImages.IMG_INDEX_PRES,-1,NULL);
+				trg->SetItemImage(indexesId,svImages.IMG_INDEXES_CHG);
+				trg->SortChildren(indexesId);
+			}
+			else
+			{
+				// ALTER table case
+				IndexElement* addIndex = new AddIndex(srcIndex); 
+				((AddIndex*)addIndex)->GenerateScript(); // this would generate the script for Table difference
+				tabScr->GetIndexScript()->AddDiffElement(addIndex);
+
+				// UI changes
+				wxTreeItemId tableId = trgTable->GetObject()->GetId();
+				wxCookieType cookie;
+				wxTreeItemId columnsId = trg->GetFirstChild(tableId,cookie);
+				wxTreeItemId constraintsId = trg->GetNextSibling(columnsId);
+				wxTreeItemId indexesId = trg->GetNextSibling(constraintsId);
+				trg->AppendItem(indexesId,indName,svImages.IMG_INDEX_PRES,-1,NULL);
+				trg->SetItemImage(indexesId,svImages.IMG_INDEXES_CHG);
+				trg->SortChildren(indexesId);
+			}
+			////////////////////////////////////////////////////////////////////////////////////////////
+		}
+		else // index got matched
+		{
+			bool indexChangesExist=false;
+			IndexDiff * trgIndex = (IndexDiff*)trgTable->FindIndexObj(indName);
+			indexChangesExist = srcIndex->GenStructuralDiff(trgIndex,src,trg,NULL,tabScr->GetIndexScript());
+			if(indexChangesExist)
+			{
+				this->tableChangesExist=true;
+				indexChangesExist=false;
+			}
+		}
+	}
+	
+	if(trgTable)
+	{
+		for(size_t i=0; i < (trgTable->GetIndexObjList().GetCount()) ; i++)
+		{
+			IndexDiff *trgIndex = (IndexDiff *)(trgTable->GetIndexObjList()).Item(i); 
+	
+			wxString indName  = trgIndex->GetIndex()->GetName();
+			if(!this->IsIndexPresent(indName)) 
+			{ 
+				pgIndex* pgi = trgIndex->GetIndex();
+				this->tableChangesExist=true;
+				
+				int obj = tabScr->GetIndexScript()->SearchObject(pgi->GetTable()->GetName(),pgi->GetName(),DROPINDEX,pgi->GetSchema()->GetName());
+				if(obj==wxNOT_FOUND) // if the drop index not is already entered by drop column
+				{
+					DropIndex * dropIndex = new DropIndex(trgIndex);
+					((DropIndex*)dropIndex)->GenerateScript();
+					tabScr->GetIndexScript()->AddDiffElement(dropIndex);
+				}
+				// performing UI changes
+				// showing present elements @ target
+				////////////////////////////////////
+				trg->SetItemImage(pgi->GetId(),svImages.IMG_INDEX_MISS);
+				wxTreeItemId id = trg->GetItemParent(pgi->GetId());
+				trg->SetItemImage(id,svImages.IMG_INDEXES_CHG);
+				/////////////////////////////////////
+			}
+		}
+	}
+}
+void TableDiff::GenStrColumnDiff(DiffObject * trgTab,ctlTree* src, ctlTree * trg,wxTreeItemId dummyColumnsId,TableScript * tabScr,ViewScript*viewScr)
+{
+	TableDiff * trgTable = (TableDiff *)trgTab;
+	// searching for the schema objects not present in trg
+	for(size_t i=0; i < (this->colObjList.GetCount()) ; i++)
+	{
+		ColumnDiff *srcColumn = (ColumnDiff *)(this->colObjList.Item(i)); 
+		wxString colName  = srcColumn->GetColumn()->GetName();
+		
+		if(!trgTable ||  // trgTable would be null when table is not present at the target 
+			!trgTable->IsColPresent(colName)) // if schema is present but schema objects are missing in target
+		{ 
+			pgColumn* pgc = srcColumn->GetColumn();
+			this->tableChangesExist=true;
+			
+			wxTreeItemId columnsId;
+			columnsId = dummyColumnsId;
+			if(!trgTable)  // adding the whole table sub tree
+			{	
+				// CREATE table case
+				CreateColumn *crtColumn = new CreateColumn(srcColumn); 
+				((CreateColumn*)crtColumn)->GenerateScript(); // this would generate the script for Table difference
+				tabScr->GetColumnScript()->AddDiffElement(crtColumn);
+
+				//UI changes
+				// showing its missing in target
+				trg->AppendItem(columnsId,colName,svImages.IMG_COLUMN_PRES,-1,NULL);
+				trg->SetItemImage(columnsId,svImages.IMG_COLUMNS_CHG);
+				trg->SortChildren(columnsId);
+			}
+			else
+			{
+				// ALTER table case
+				// Add Column case as the table is there
+				AddColumn *addColumn = new AddColumn(srcColumn); 
+				((AddColumn*)addColumn)->GenerateScript(); // this would generate the script for Table difference
+				tabScr->GetColumnScript()->AddDiffElement(addColumn);
+ 
+				// UI changes
+				wxTreeItemId tableId = trgTable->GetObject()->GetId();
+				wxCookieType cookie;
+				wxTreeItemId columnsId = trg->GetFirstChild(tableId,cookie);
+				trg->AppendItem(columnsId,colName,svImages.IMG_COLUMN_PRES,-1,NULL);
+				trg->SetItemImage(columnsId,svImages.IMG_COLUMNS_CHG);  
+				trg->SortChildren(columnsId);
+			}
+			////////////////////////////////////////////////////////////////////////////////////////////
+		}
+		else // column got matched
+		{
+			bool colChangesExist;
+			ColumnDiff * trgColumn = (ColumnDiff*)trgTable->FindColObj(colName);
+			colChangesExist = srcColumn->GenStructuralDiff(trgColumn,src,trg,NULL,tabScr->GetColumnScript());
+			if(colChangesExist)
+			{
+				this->tableChangesExist=true;
+				colChangesExist=false;
+			}
+		}
+	}
+	// searching for the column objects not present in source
+	if(trgTable)
+	{
+		for(size_t i=0; i < (trgTable->GetColumnObjList().GetCount()) ; i++)
+		{
+			ColumnDiff *trgColumn = (ColumnDiff *)(trgTable->GetColumnObjList()).Item(i); 
+	
+			wxString colName  = trgColumn->GetColumn()->GetName();
+			if(!this->IsColPresent(colName)) 
+			{ 
+				pgColumn* pgc = trgColumn->GetColumn();
+				this->tableChangesExist=true;
+				
+				// performing UI changes
+
+				// showing present elements @ target
+				////////////////////////////////////
+				trg->SetItemImage(pgc->GetId(),svImages.IMG_COLUMN_MISS);
+				wxTreeItemId id = trg->GetItemParent(pgc->GetId());
+				trg->SetItemImage(id,svImages.IMG_COLUMNS_CHG);
+				/////////////////////////////////////
+
+				ColumnElement *dropColumn = new DropColumn(trgColumn);
+				wxString tabname = pgc->GetTable()->GetName();
+				wxString schname = pgc->GetSchema()->GetName();
+				
+				////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+				// checking dependency and adding required dependent obj to drop this obj
+				DependentObjArray depList;
+				wxString where;
+				where += wxT("\n WHERE dep.refobjid=") + pgc->GetTable()->GetOidStr() +
+						wxT(" AND dep.refobjsubid=") + NumToStr(pgc->GetColNumber());
+
+				
+				DiffObject::GetDependents(pgc,depList,where);
+				if(!depList.IsEmpty())
+					BindDropColumnDependents(tabScr,viewScr,depList,dropColumn,pgc);
+
+				((DropColumn*)dropColumn)->GenerateScript();
+				tabScr->GetColumnScript()->AddDiffElement(dropColumn);
+			}
+			//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+		}
+	}
+}
+void TableDiff::GenStrUniqueDiff(DiffObject * trgTab,ctlTree* src, ctlTree * trg,wxTreeItemId dummyConstraintsId,TableScript *tabScr)
+{
+	TableDiff * trgTable = (TableDiff *)trgTab;
+	// searching for the schema objects not present in trg
+	for(size_t i=0; i < (this->uniqueObjList.GetCount()) ; i++)
+	{
+		UniqueDiff *srcUnique = (UniqueDiff *)(this->uniqueObjList.Item(i)); 
+		wxString uniqueName  = srcUnique->GetUnique()->GetName();
+		
+		if(!trgTable ||  // trgTable would be null when table is not present at the target 
+			!trgTable->FindUniqueObj(uniqueName)) // if schema is present but schema objects are missing in target
+		{ 
+			pgUnique* pgu = srcUnique->GetUnique();
+			this->tableChangesExist=true;
+			
+			wxTreeItemId constraintsId;
+			constraintsId = dummyConstraintsId;
+			
+			if(!trgTable)  // adding the whole table sub tree  
+			{
+				// CREATE table case
+				CreateUnique* crtUnique = new CreateUnique(srcUnique); 
+				((CreateUnique*)crtUnique)->GenerateScript(); // this would generate the script for Table difference
+				tabScr->GetUniqueScript()->AddDiffElement(crtUnique);
+			
+				// UI changes
+				trg->AppendItem(constraintsId,uniqueName,svImages.IMG_UNIQUE_PRES,-1,NULL);
+				trg->SetItemImage(constraintsId,svImages.IMG_CONSTRAINTS_CHG);
+				trg->SortChildren(constraintsId);
+			}
+			else 
+			{
+				// ALTER table case
+				AddUnique* addUnique = new AddUnique(srcUnique); 
+				((AddUnique*)addUnique)->GenerateScript(); // this would generate the script for Table difference
+				tabScr->GetUniqueScript()->AddDiffElement(addUnique);
+			
+				// UI changes
+				wxTreeItemId tableId = trgTable->GetObject()->GetId();
+				wxCookieType cookie;
+				wxTreeItemId columnsId = trg->GetFirstChild(tableId,cookie);
+				wxTreeItemId constraintsId = trg->GetNextSibling(columnsId);
+				
+				trg->AppendItem(constraintsId,uniqueName,svImages.IMG_UNIQUE_PRES,-1,NULL);
+				trg->SetItemImage(constraintsId,svImages.IMG_CONSTRAINTS_CHG);
+				trg->SortChildren(constraintsId);
+			}
+			////////////////////////////////////////////////////////////////////////////////////////////
+		}
+		else // unique obj's got matched
+		{
+			bool uniqueChangesExist=false;
+			UniqueDiff * trgUnique = (UniqueDiff*)trgTable->FindUniqueObj(uniqueName);
+			uniqueChangesExist = srcUnique->GenStructuralDiff(trgUnique,src,trg,NULL,tabScr);
+			if(uniqueChangesExist)
+			{
+				this->tableChangesExist=true;
+				uniqueChangesExist=false;
+			}
+		}
+	}
+	
+	if(trgTable)
+	{
+		for(size_t i=0; i < (trgTable->GetUniqueObjList().GetCount()) ; i++)
+		{
+			UniqueDiff *trgUnique = (UniqueDiff *)(trgTable->GetUniqueObjList()).Item(i); 
+			wxString uniqueName  = trgUnique->GetUnique()->GetName();
+			if(!this->FindUniqueObj(uniqueName)) 
+			{ 
+				pgUnique* pgu = trgUnique->GetUnique();
+				this->tableChangesExist;
+				
+				// performing UI changes
+				// showing present elements @ target
+				////////////////////////////////////
+				trg->SetItemImage(pgu->GetId(),svImages.IMG_UNIQUE_MISS);
+				wxTreeItemId id = trg->GetItemParent(pgu->GetId());
+				trg->SetItemImage(id,svImages.IMG_CONSTRAINTS_CHG);
+				/////////////////////////////////////
+
+				DropUnique * dropUnique = new DropUnique(trgUnique);
+
+				wxString name = pgu->GetName();
+				wxString tabname = pgu->GetTable()->GetName();
+				wxString schname = pgu->GetSchema()->GetName();
+
+				//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+				// checking dependency and adding required dependent obj to drop this obj
+				DependentObjArray depList;
+				wxString where;
+				TableDiff::GetDependents(pgu,depList,where);
+				
+				int obj = tabScr->GetUniqueScript()->SearchObject(pgu->GetTable()->GetName(),pgu->GetName(),DROPUNIQUE,pgu->GetSchema()->GetName());
+				if(obj==wxNOT_FOUND)
+				{
+					if(!depList.IsEmpty())
+						BindDropUniqueDependents(tabScr,depList,dropUnique,pgu);
+					
+					((DropUnique*)dropUnique)->GenerateScript();
+					tabScr->GetUniqueScript()->AddDiffElement(dropUnique);
+				}
+				//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+			}
+		}
+	}
+}
+void TableDiff::BindDropPkDependents(TableScript *tabScr,DependentObjArray &depList,PkElement *pkElem,pgObject *pkObject)
+{
+	DropPk *dropPk = (DropPk*)pkElem;
+	pgPrimaryKey *pgp = (pgPrimaryKey*)pkObject;
+
+	int depIndex;
+	for(size_t i=0; i<depList.GetCount(); i++)
+	{
+		DependencyObj * dobj= (DependencyObj*)depList.Item(i);
+
+		if(!dobj->tableName) // tableName is empty when unique is auto type
+		{
+			dobj->tableName = pgp->GetTable()->GetName();
+			dobj->schemaName = TableDiff::RemoveQuotes(dobj->schemaName);
+			dobj->objName = TableDiff::RemoveQuotes(dobj->objName);
+		}
+		else
+		{
+			dobj->tableName = TableDiff::RemoveQuotes(dobj->tableName);
+			dobj->schemaName = TableDiff::RemoveQuotes(dobj->schemaName);
+			dobj->objName = TableDiff::RemoveQuotes(dobj->objName);
+		}
+		// could add more cases if required
+		if(dobj->objTypeName == wxT("Foreign Key"))
+		{
+			// already there 
+			depIndex = tabScr->GetFkScript()->SearchObject(dobj->tableName,dobj->objName,DROPFK,dobj->schemaName);
+			if(depIndex == wxNOT_FOUND) 
+			{
+				// create a drop obj for dependent and add to list
+				FkElement * dropDependent = new DropFk(dobj->tableName,dobj->objName,dobj->schemaName);
+				((DropFk*)dropDependent)->GenerateScript();
+				tabScr->GetFkScript()->AddDiffElement(dropDependent);
+				
+				// getting the index of the added obj
+				depIndex = tabScr->GetFkScript()->SearchObject(dobj->tableName,dobj->objName,DROPFK,dobj->schemaName); 
+				if(depIndex !=wxNOT_FOUND) // this would always be true, just checking
+					dropPk->iSetPkDepFkId(depIndex); // binding the dependent and non-dependent
+			}
+			else
+			{
+				; // do nothing as the columns would take care of the dependents
+			}
+		}
+	}
+}
+void TableDiff::BindDropUniqueDependents(TableScript *tabScr,DependentObjArray &depList,UniqueElement* uniElem,pgObject * uniqueObject)
+{
+	DropUnique *dropUnique = (DropUnique*)uniElem;
+	pgUnique *pgu = (pgUnique*)uniqueObject;
+
+	int depIndex;
+	for(size_t i=0; i<depList.GetCount(); i++)
+	{
+		DependencyObj * dobj= (DependencyObj*)depList.Item(i);
+		if(!dobj->tableName) // tableName is empty when unique is auto type
+		{
+			dobj->tableName = pgu->GetTable()->GetName();
+			dobj->schemaName = TableDiff::RemoveQuotes(dobj->schemaName);
+			dobj->objName = TableDiff::RemoveQuotes(dobj->objName);
+		}
+		else
+		{
+			dobj->tableName = TableDiff::RemoveQuotes(dobj->tableName);
+			dobj->schemaName = TableDiff::RemoveQuotes(dobj->schemaName);
+			dobj->objName = TableDiff::RemoveQuotes(dobj->objName);
+		}
+		
+		// could add more cases if required
+		if(dobj->objTypeName == wxT("Foreign Key"))
+		{
+			// already there 
+			depIndex = tabScr->GetFkScript()->SearchObject(dobj->tableName,dobj->objName,DROPFK,dobj->schemaName);
+			if(depIndex == wxNOT_FOUND) 
+			{
+				// create a drop obj for dependent and add to list
+				FkElement * dropDependent = new DropFk(dobj->tableName,dobj->objName,dobj->schemaName);
+				((DropFk*)dropDependent)->GenerateScript();
+				tabScr->GetFkScript()->AddDiffElement(dropDependent);
+				
+				// getting the index of the added obj
+				depIndex = tabScr->GetFkScript()->SearchObject(dobj->tableName,dobj->objName,DROPFK,dobj->schemaName); 
+				if(depIndex !=wxNOT_FOUND) // this would always be true, just checking
+					dropUnique->iSetUniqueDepFkId(depIndex); // binding the dependent and non-dependent
+				
+			}
+			else
+			{
+				; // do nothing as the columns would take care of the dependents already
+			}
+		}
+	}
+}
+void TableDiff::BindDropColumnDependents(TableScript *tabScr,ViewScript* viewScr,DependentObjArray &depList,ColumnElement* colElem,pgObject * columnObject)
+{
+	DropColumn *dropColumn = (DropColumn*)colElem;
+	pgColumn *pgc = (pgColumn*)columnObject;
+	wxString colName = pgc->GetName();
+	wxString tabName = pgc->GetTable()->GetName();
+	wxString schName = pgc->GetSchema()->GetName();
+	if(!depList.IsEmpty()) // if the obj to be dropped has some dependents
+	{
+		int depIndex;
+		for(size_t i=0; i<depList.GetCount(); i++)
+		{
+			DependencyObj * dobj= (DependencyObj*)depList.Item(i);
+
+			if(!dobj->tableName) // tableName is empty when unique is auto type
+				dobj->tableName = pgc->GetTable()->GetName();
+				
+			if(dobj->objTypeName == wxT("Foreign Key"))
+			{
+				depIndex = tabScr->GetFkScript()->SearchObject(dobj->tableName,dobj->objName,DROPFK,dobj->schemaName);
+				if(depIndex == wxNOT_FOUND) // not found add it to FkScript 
+				{
+					// create a drop obj for dependent and add to list
+					FkElement * dropDependent = new DropFk(dobj->tableName,dobj->objName,dobj->schemaName);
+					((DropFk*)dropDependent)->GenerateScript();
+					tabScr->GetFkScript()->AddDiffElement(dropDependent);
+					
+					// getting the index of the added obj
+					depIndex = tabScr->GetFkScript()->SearchObject(dobj->tableName,dobj->objName,DROPFK,dobj->schemaName); 
+					if(depIndex !=wxNOT_FOUND) // this would always be true, just checking
+						dropColumn->iSetColDepFkId(depIndex); // binding the dependent and non-dependent
+				}
+				else
+				{
+					dropColumn->iSetColDepFkId(depIndex); 
+				}
+			}
+			else if(dobj->objTypeName == wxT("Primary Key"))
+			{
+				depIndex = tabScr->GetPkScript()->SearchObject(dobj->tableName,dobj->objName,DROPPK,dobj->schemaName);
+				if(depIndex == wxNOT_FOUND) 
+				{
+					// create a drop obj for dependent and add to list
+					PkElement * dropDependent = new DropPk(dobj->tableName,dobj->objName,dobj->schemaName);
+					((DropPk*)dropDependent)->GenerateScript();
+					tabScr->GetPkScript()->AddDiffElement(dropDependent);
+					
+					// getting the index of the added obj
+					depIndex = tabScr->GetPkScript()->SearchObject(dobj->tableName,dobj->objName,DROPPK,dobj->schemaName); 
+					if(depIndex !=wxNOT_FOUND) // this would always be true, just checking
+						dropColumn->iSetColDepPkId(depIndex); // binding the dependent and non-dependent
+				}
+				else
+				{
+					dropColumn->iSetColDepPkId(depIndex); 
+				}
+			}
+			else if(dobj->objTypeName == wxT("Index"))
+			{
+				depIndex = tabScr->GetIndexScript()->SearchObject(dobj->tableName,dobj->objName,DROPINDEX,dobj->schemaName);
+				if(depIndex == wxNOT_FOUND) 
+				{
+					// create a drop obj for dependent and add to list
+					IndexElement * dropDependent = new DropIndex(dobj->tableName,dobj->objName,dobj->schemaName);
+					((DropIndex*)dropDependent)->GenerateScript();
+					tabScr->GetIndexScript()->AddDiffElement(dropDependent);
+					
+					// getting the index of the added obj
+					depIndex = tabScr->GetIndexScript()->SearchObject(dobj->tableName,dobj->objName,DROPINDEX,dobj->schemaName); 
+					if(depIndex !=wxNOT_FOUND) // this would always be true, just checking
+						dropColumn->iSetColDepIndexId(depIndex); // binding the dependent and non-dependent
+				}
+				else
+				{
+					dropColumn->iSetColDepIndexId(depIndex); 
+				}
+			}
+			else if(dobj->objTypeName == wxT("Unique"))
+			{
+				depIndex = tabScr->GetUniqueScript()->SearchObject(dobj->tableName,dobj->objName,DROPUNIQUE,dobj->schemaName);
+				if(depIndex == wxNOT_FOUND) 
+				{
+					// create a drop obj for dependent and add to list
+					UniqueElement * dropDependent = new DropUnique(dobj->tableName,dobj->objName,dobj->schemaName);
+					((DropUnique*)dropDependent)->GenerateScript();
+					tabScr->GetUniqueScript()->AddDiffElement(dropDependent);
+					
+					// getting the index of the added obj
+					depIndex = tabScr->GetUniqueScript()->SearchObject(dobj->tableName,dobj->objName,DROPUNIQUE,dobj->schemaName); 
+					if(depIndex !=wxNOT_FOUND) // this would always be true, just checking
+						dropColumn->iSetColDepUniqueId(depIndex); // binding the dependent and non-dependent
+				}
+				else
+				{
+					dropColumn->iSetColDepUniqueId(depIndex); 
+				}
+			}
+			else if(dobj->objTypeName == wxT("Rule"))
+			{
+				// for this need view script as column has a dependent rule which has a dependent view.
+				depIndex = viewScr->SearchObject(dobj->tableName,DROPVIEW,dobj->schemaName);
+				if(depIndex == wxNOT_FOUND) 
+				{
+					// create a drop obj for dependent and add to list
+					ViewElement * dropDependent = new DropView(dobj->tableName,dobj->schemaName);
+					((DropView*)dropDependent)->GenerateScript();
+					viewScr->AddDiffElement(dropDependent);
+					
+					// getting the index of the added obj
+					depIndex = viewScr->SearchObject(dobj->tableName,DROPVIEW,dobj->schemaName); 
+					if(depIndex !=wxNOT_FOUND) // this would always be true, just checking
+						dropColumn->iSetColDepViewId(depIndex); // binding the dependent and non-dependent
+				}
+				else
+				{
+					dropColumn->iSetColDepViewId(depIndex); 
+				}
+			}
+		}
+	}
+}
+
+void TableDiff::DropTableObject(DiffObject * trgTable,ctlTree * src, ctlTree * trg,TableScript * tabScr,ViewScript* viewScr)
+{
+	// dropping all the lower level objects inside a table
+	DropColumnObject(trgTable,src,trg,tabScr,viewScr);
+	DropPkObject(trgTable,src,trg,tabScr);
+	DropFkObject(trgTable,src,trg,tabScr);
+	DropUniqueObject(trgTable,src,trg,tabScr);
+	DropIndexObject(trgTable,src,trg,tabScr);
+
+}
+void TableDiff::DropColumnObject(DiffObject * trgTab,ctlTree * src, ctlTree * trg,TableScript * tabScr,ViewScript *viewScr)
+{
+	// write this
+	TableDiff * trgTable = (TableDiff *)trgTab;
+	for(size_t i=0; i < (trgTable->GetColumnObjList().GetCount()) ; i++)
+	{
+		ColumnDiff *trgColumn = (ColumnDiff *)(trgTable->GetColumnObjList()).Item(i); 
+		wxString colName  = trgColumn->GetColumn()->GetName();
+		pgColumn* pgc = trgColumn->GetColumn();
+		
+		ColumnElement *dropColumn = new DropColumn(trgColumn);
+		////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+		// checking dependency and adding required dependent obj to drop this obj
+		DependentObjArray depList;
+		wxString where;
+		where += wxT("\n WHERE dep.refobjid=") + pgc->GetTable()->GetOidStr() +
+				wxT(" AND dep.refobjsubid=") + NumToStr(pgc->GetColNumber());
+
+		DiffObject::GetDependents(pgc,depList,where);
+		if(!depList.IsEmpty())
+			TableDiff::BindDropColumnDependents(tabScr,viewScr,depList,dropColumn,pgc);
+		
+		((DropColumn*)dropColumn)->GenerateScript();
+		tabScr->GetColumnScript()->AddDiffElement(dropColumn);
+
+		
+		// performing UI changes
+		// showing drop elements @ target
+		////////////////////////////////////
+		trg->SetItemImage(pgc->GetId(),svImages.IMG_COLUMN_MISS);
+		wxTreeItemId id = trg->GetItemParent(pgc->GetId());
+		trg->SetItemImage(id,svImages.IMG_COLUMNS_CHG);
+		/////////////////////////////////////
+	}
+}
+void TableDiff::DropPkObject(DiffObject * trgTab,ctlTree * src, ctlTree * trg,TableScript * tabScr)
+{
+	TableDiff * trgTable = (TableDiff *)trgTab;
+	PkDiff *trgPk = trgTable->GetPk(); 
+	if(trgPk)
+	{
+		wxString pkName  = trgPk->GetPk()->GetName();
+		pgPrimaryKey *pgp = trgPk->GetPk();
+		
+	
+		////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+		// checking dependency and adding required dependent obj to drop this obj
+		DependentObjArray depList;
+		wxString where;
+		TableDiff::GetDependents(pgp,depList,where);
+
+		DropPk * dropPk = new DropPk(trgPk);
+		int obj = tabScr->GetPkScript()->SearchObject(pgp->GetTable()->GetName(),pgp->GetName(),DROPPK,pgp->GetSchema()->GetName());
+		if(obj==wxNOT_FOUND) // if the drop index is not already entered by drop column
+		{
+			if(!depList.IsEmpty())
+				BindDropPkDependents(tabScr,depList,dropPk,pgp);
+				
+			((DropPk*)dropPk)->GenerateScript();
+			tabScr->GetPkScript()->AddDiffElement(dropPk);
+		}
+		else
+		{
+			;// do nothing
+		}
+		////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+		//UI changes
+		// showing present elements @ target
+		////////////////////////////////////
+		trg->SetItemImage(pgp->GetId(),svImages.IMG_PK_MISS);
+		wxTreeItemId id = trg->GetItemParent(pgp->GetId());
+		trg->SetItemImage(id,svImages.IMG_CONSTRAINTS_CHG);
+		/////////////////////////////////////
+	
+	}
+}
+void TableDiff::DropFkObject(DiffObject * trgTab,ctlTree * src, ctlTree * trg,TableScript * tabScr)
+{
+	TableDiff * trgTable = (TableDiff *)trgTab;
+	for(size_t i=0; i < (trgTable->GetFkObjList().GetCount()) ; i++)
+	{
+		FkDiff *trgFk = (FkDiff *)(trgTable->GetFkObjList()).Item(i); 
+
+		wxString fkName  = trgFk->GetFk()->GetName();
+		pgForeignKey *pgf = trgFk->GetFk();
+		
+		DropFk *dropFk = new DropFk(trgFk);
+		int obj = tabScr->GetFkScript()->SearchObject(pgf->GetTable()->GetName(),pgf->GetName(),DROPFK,pgf->GetSchema()->GetName());
+		if(obj==wxNOT_FOUND)
+		{
+			DropFk * dropFk = new DropFk(trgFk);
+			((DropFk*)dropFk)->GenerateScript();
+			tabScr->GetFkScript()->AddDiffElement(dropFk);
+		}
+
+		// showing present elements @ target
+		////////////////////////////////////
+		trg->SetItemImage(pgf->GetId(),svImages.IMG_FK_MISS);
+		wxTreeItemId id = trg->GetItemParent(pgf->GetId());
+		trg->SetItemImage(id,svImages.IMG_CONSTRAINTS_CHG);
+		/////////////////////////////////////
+	}
+}
+void TableDiff::DropUniqueObject(DiffObject * trgTab,ctlTree * src, ctlTree * trg,TableScript * tabScr)
+{
+	TableDiff * trgTable = (TableDiff *)trgTab;
+	for(size_t i=0; i < (trgTable->GetUniqueObjList().GetCount()) ; i++)
+	{
+		UniqueDiff *trgUnique = (UniqueDiff *)(trgTable->GetUniqueObjList()).Item(i); 
+		wxString uniqueName  = trgUnique->GetUnique()->GetName();
+		pgUnique* pgu = trgUnique->GetUnique();
+		
+		DropUnique * dropUnique = new DropUnique(trgUnique);
+
+		//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+		// checking dependency and adding required dependent obj to drop this obj
+		DependentObjArray depList;
+		wxString where;
+		TableDiff::GetDependents(pgu,depList,where);
+		wxString schName = pgu->GetSchema()->GetName();
+		wxString tabName = pgu->GetTable()->GetName();
+		
+		int obj = tabScr->GetUniqueScript()->SearchObject(pgu->GetTable()->GetName(),pgu->GetName(),DROPUNIQUE,pgu->GetSchema()->GetName());
+		if(obj==wxNOT_FOUND)
+		{
+			if(!depList.IsEmpty())
+				TableDiff::BindDropUniqueDependents(tabScr,depList,dropUnique,pgu);
+			
+			((DropUnique*)dropUnique)->GenerateScript();
+			tabScr->GetUniqueScript()->AddDiffElement(dropUnique);
+		}
+
+		// showing present elements @ target
+		////////////////////////////////////
+		trg->SetItemImage(pgu->GetId(),svImages.IMG_UNIQUE_MISS);
+		wxTreeItemId id = trg->GetItemParent(pgu->GetId());
+		trg->SetItemImage(id,svImages.IMG_CONSTRAINTS_CHG);
+		/////////////////////////////////////
+	}
+}
+void TableDiff::DropIndexObject(DiffObject * trgTab,ctlTree * src, ctlTree * trg,TableScript *tabScr)
+{
+	TableDiff * trgTable = (TableDiff *)trgTab;
+	for(size_t i=0; i < (trgTable->GetIndexObjList().GetCount()) ; i++)
+	{
+		IndexDiff *trgIndex = (IndexDiff *)(trgTable->GetIndexObjList()).Item(i); 
+
+		wxString indName  = trgIndex->GetIndex()->GetName();
+		pgIndex* pgi = trgIndex->GetIndex();
+			
+		int obj = tabScr->GetIndexScript()->SearchObject(pgi->GetTable()->GetName(),pgi->GetName(),DROPINDEX,pgi->GetSchema()->GetName());
+		if(obj==wxNOT_FOUND) // if the drop index not is already entered by drop column
+		{
+			DropIndex * dropIndex = new DropIndex(trgIndex);
+			((DropIndex*)dropIndex)->GenerateScript();
+			tabScr->GetIndexScript()->AddDiffElement(dropIndex);
+		}
+		
+		/////////////////////////////////////
+		// showing present elements @ target
+		////////////////////////////////////
+		trg->SetItemImage(pgi->GetId(),svImages.IMG_INDEX_MISS);
+		wxTreeItemId id = trg->GetItemParent(pgi->GetId());
+		trg->SetItemImage(id,svImages.IMG_INDEXES_CHG);
+		/////////////////////////////////////
+	
+	}
+
+}
+// this would provide with dependends of 
+// pk,unique,fk or else
+void TableDiff::FetchDep(pgObject * obj,const wxString query, const wxString &clsorder,DependentObjArray &depList)
+{
+	pgDatabase *db = obj->GetDatabase();
+	pgConn *conn = obj->GetConnection();
+	wxString name = obj->GetName();
+
+    if (conn)
+    {
+        pgSet *set;
+ 
+        set=conn->ExecuteSet(query + wxT("\n")
+            wxT("   AND ") + clsorder + wxT(" IN (\n")
+            wxT("   SELECT oid FROM pg_class\n")
+            wxT("    WHERE relname IN ('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc',\n")
+            wxT("                      'pg_rewrite', 'pg_namespace', 'pg_trigger', 'pg_type', 'pg_attrdef'))\n")
+            wxT(" ORDER BY ") + clsorder + wxT(", cl.relkind"));
+
+        if (set)
+        {
+            while (!set->Eof())
+            {
+                wxString refname;
+				wxString _refname;
+                //wxString _refname = set->GetVal(wxT("refname"));
+				DependencyObj *d = new DependencyObj();
+				 d->objName = set->GetVal(wxT("refname"));
+
+				 if (db)
+				 {
+                    //d->schemaName = db->GetQuotedSchemaPrefix(set->GetVal(wxT("nspname")));
+					 d->schemaName = set->GetVal(wxT("nspname"));
+				 }
+                else
+                {
+                    refname = qtIdent(set->GetVal(wxT("nspname")));
+                    /*if (!refname.IsEmpty())
+                        refname += wxT(".");*/
+                }
+
+                wxString typestr=set->GetVal(wxT("type"));
+                pgaFactory *depFactory=0;
+                switch (typestr.c_str()[0])
+                {
+                    case 'c':
+                    case 's':   // we don't know these; internally handled
+                    case 't':   set->MoveNext(); continue;
+
+                    case 'r':
+                    {
+                        if (StrToLong(typestr.Mid(1)) > 0)
+                            depFactory = &columnFactory;
+                        else
+                            depFactory=&tableFactory;
+                        break;
+                    }
+                    case 'i':   depFactory=&indexFactory;    break;
+                    case 'S':   depFactory=&sequenceFactory; break;
+                    case 'v':   depFactory=&viewFactory;     break;
+                    case 'x':   depFactory=&extTableFactory; break;
+                    case 'p':   depFactory=&functionFactory; break;
+                    case 'n':   depFactory=&schemaFactory;   break;
+                    case 'y':   depFactory=&typeFactory;     break;
+                    case 'T':   depFactory=&triggerFactory;  break;
+                    case 'l':   depFactory=&languageFactory; break;
+                    case 'R':
+                    {
+                        refname = _refname + wxT(" ON ") + refname + set->GetVal(wxT("ownertable"));
+						d->tableName = set->GetVal(wxT("ownertable"));
+						_refname=wxEmptyString;
+                        depFactory=&ruleFactory;
+                        break;
+                    }
+                    case 'C':
+                    {
+                        switch (typestr.c_str()[1])
+                        {
+                            case 'c':   depFactory=&checkFactory;        break;
+                            case 'f':   
+                                //refname += set->GetVal(wxT("ownertable")) + wxT(".");
+								d->tableName = set->GetVal(wxT("ownertable"));
+                                depFactory=&foreignKeyFactory;   break;
+                            case 'p':   depFactory=&primaryKeyFactory;   break;
+                            case 'u':   depFactory=&uniqueFactory;       break;
+                            default:    break;
+                        }
+                        break;
+                    }
+                    case 'A':
+                    {
+                        // Include only functions
+                        if (set->GetVal(wxT("adbin")).StartsWith(wxT("{FUNCEXPR")))
+                        {
+                            depFactory=&functionFactory;
+                            refname = set->GetVal(wxT("adsrc"));
+                            break;
+                        }
+                        else
+                        {
+                            set->MoveNext();
+                            continue;
+                        }
+                    }
+                    default:
+                        break;
+                }
+
+                refname += _refname;
+
+                wxString typname;
+                int icon;
+                if (depFactory)
+                {
+                    //typname = depFactory->GetTypeName();
+					d->objTypeName = depFactory->GetTypeName();
+                    icon = depFactory->GetIconId();
+                }
+                else
+                {
+                    typname = _("Unknown");
+                    icon=-1;
+                }
+
+                wxString deptype;
+
+                switch (set->GetVal(wxT("deptype")).c_str()[0])
+                {
+                    case 'n':   deptype=wxT("normal");      break;
+                    case 'a':   deptype=wxT("auto");        break;
+                    case 'i': 
+                    {
+                        if (settings->GetShowSystemObjects())
+                            deptype=wxT("internal");
+                        else
+                        {
+                            set->MoveNext();
+                            continue;
+                        }
+                        break;
+                    }
+                    case 'p':   deptype=wxT("pin");  typname=wxEmptyString;        break;
+                    default:                                break;
+                }
+
+				depList.Add(d);
+                set->MoveNext();
+            }
+            delete set;
+        }
+    }
+}
+void TableDiff::GetDependents(pgObject * obj,DependentObjArray &depList,const wxString &wh)
+{
+    wxString where;
+	wxString name = obj->GetName();
+	
+    if (wh.IsEmpty())
+        where = wxT(" WHERE dep.refobjid=") + obj->GetOidStr();
+    else
+        where = wh;
+    
+
+	wxString query;
+	FetchDep(obj,wxT("SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc, \n")
+        wxT("       CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.objsubid::text, '')\n")
+        wxT("            WHEN tg.oid IS NOT NULL THEN 'T'::text\n")
+        wxT("            WHEN ty.oid IS NOT NULL THEN 'y'::text\n")
+        wxT("            WHEN ns.oid IS NOT NULL THEN 'n'::text\n")
+        wxT("            WHEN pr.oid IS NOT NULL THEN 'p'::text\n")
+        wxT("            WHEN la.oid IS NOT NULL THEN 'l'::text\n")
+        wxT("            WHEN rw.oid IS NOT NULL THEN 'R'::text\n")
+        wxT("            WHEN co.oid IS NOT NULL THEN 'C'::text || contype\n")
+        wxT("            WHEN ad.oid IS NOT NULL THEN 'A'::text\n")
+        wxT("            ELSE '' END AS type,\n")
+        wxT("       COALESCE(coc.relname, clrw.relname) AS ownertable,\n")
+        wxT("       CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname \n")
+        wxT("            ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname) \n")
+        wxT("       END AS refname,\n")
+        wxT("       COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname\n")
+        wxT("  FROM pg_depend dep\n")
+        wxT("  LEFT JOIN pg_class cl ON dep.objid=cl.oid\n")
+        wxT("  LEFT JOIN pg_attribute att ON dep.objid=att.attrelid AND dep.objsubid=att.attnum\n")
+        wxT("  LEFT JOIN pg_namespace nsc ON cl.relnamespace=nsc.oid\n")
+        wxT("  LEFT JOIN pg_proc pr ON dep.objid=pr.oid\n")
+        wxT("  LEFT JOIN pg_namespace nsp ON pr.pronamespace=nsp.oid\n")
+        wxT("  LEFT JOIN pg_trigger tg ON dep.objid=tg.oid\n")
+        wxT("  LEFT JOIN pg_type ty ON dep.objid=ty.oid\n")
+        wxT("  LEFT JOIN pg_namespace nst ON ty.typnamespace=nst.oid\n")
+        wxT("  LEFT JOIN pg_constraint co ON dep.objid=co.oid\n")
+        wxT("  LEFT JOIN pg_class coc ON co.conrelid=coc.oid\n")
+        wxT("  LEFT JOIN pg_namespace nso ON co.connamespace=nso.oid\n")
+        wxT("  LEFT JOIN pg_rewrite rw ON dep.objid=rw.oid\n")
+        wxT("  LEFT JOIN pg_class clrw ON clrw.oid=rw.ev_class\n")
+        wxT("  LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid\n")
+        wxT("  LEFT JOIN pg_language la ON dep.objid=la.oid\n")
+        wxT("  LEFT JOIN pg_namespace ns ON dep.objid=ns.oid\n")
+        wxT("  LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid\n")
+        + where, wxT("classid"),depList);
+}
+
+wxString TableDiff::RemoveQuotes(wxString str)
+{
+	wxString abc=str.Mid(1,str.length()-1);
+	return abc;
+}
+/////////////////////////////////////////////////////////////////////////////////////////////////
+void TableScript::Initialize (ViewScript * viewScr)
+{
+	fkScript = new FkScript();
+	pkScript = new PkScript();
+	indexScript = new IndexScript();
+	columnScript = new ColumnScript();
+	uniqueScript = new UniqueScript();
+	viewScript = viewScr;
+}
+void TableScript::GenerateScript()
+{
+}
+wxString TableScript::GenerateCreateScript(wxString schemaName)
+{
+	wxString createTableScript,tmp;
+	for(size_t i=0; i<this->tableDiffList.GetCount();i++)
+	{
+		TableElement *tabElem = this->tableDiffList.Item(i);
+		wxString schName = tabElem->GetSchemaName();
+
+		
+		if(tabElem->GetMetaType() == CRTTABLE && tabElem->GetSchemaName() == schemaName)
+		{
+			createTableScript+=tabElem->GetScript(); // getting the table name
+			tmp=this->CreateTableScript(tabElem->GetTableName(),tabElem->GetSchemaName());
+			if(tmp.length()>0)
+				createTableScript+=tmp;
+		}
+	}
+	return createTableScript;
+}
+
+wxString TableScript::GenerateAlterScript(wxString schemaName)
+{
+	CreateTableArray createTableIndexes;
+	AlterTableArray  alterTableIndexes;
+	DropTableArray   dropTableIndexes;
+	CreatingIndexes(schemaName,createTableIndexes,alterTableIndexes,dropTableIndexes);
+
+	 /*
+	 Order of application
+	 drop table -> drop table lower objects => create a new table => add/alter table lower objects
+	 */
+
+	wxString alterTableScript,tmp;
+
+	// drop tables
+	for(size_t i=0; i<dropTableIndexes.GetCount();i++)
+	{
+		int index= dropTableIndexes.Item(i);
+		TableElement *tabElem = this->tableDiffList.Item(index);
+		wxString name = tabElem->GetSchemaName();
+		int m = tabElem->GetMetaType();
+
+		if(tabElem->GetMetaType() == DROPTABLE && tabElem->GetSchemaName() == schemaName)
+		{
+			tmp=this->DropTableScript(tabElem->GetTableName(),tabElem->GetSchemaName());
+			if(tmp.length()>0)
+				alterTableScript+=tmp;
+			
+			alterTableScript+=tabElem->GetScript();
+		}
+
+	}
+	// dropping lower objects inside tables
+	for(size_t i=0; i<alterTableIndexes.GetCount();i++)
+	{
+		int index= alterTableIndexes.Item(i);
+		TableElement *tabElem = this->tableDiffList.Item(index);
+		
+		if(tabElem->GetMetaType() == ALTERTABLE && tabElem->GetSchemaName() == schemaName)
+		{
+			tmp=this->AlterTableScript(tabElem->GetTableName(),tabElem->GetSchemaName(),wxT("DROP"));
+			if(tmp.length()>0)
+				alterTableScript+=tmp;
+		}
+	}
+	// creating tables
+	for(size_t i=0; i<createTableIndexes.GetCount();i++)
+	{
+		int index= createTableIndexes.Item(i);
+		TableElement *tabElem = this->tableDiffList.Item(index);
+		
+		wxString schName = tabElem->GetSchemaName();
+		wxString tabName = tabElem->GetTableName();
+		
+		if(tabElem->GetMetaType() == CRTTABLE && tabElem->GetSchemaName() == schemaName)
+		{
+			alterTableScript+=tabElem->GetScript();
+			tmp=this->CreateTableScript(tabElem->GetTableName(),tabElem->GetSchemaName());
+			if(tmp.length()>0)
+				alterTableScript+=tmp;
+		}
+	}
+	// adding and altering tables lower objects
+	for(size_t i=0; i<alterTableIndexes.GetCount();i++)
+	{
+		int index= alterTableIndexes.Item(i);
+		TableElement *tabElem = this->tableDiffList.Item(index);
+		
+		if(tabElem->GetMetaType() == ALTERTABLE && tabElem->GetSchemaName() == schemaName)
+		{
+			tmp=this->AlterTableScript(tabElem->GetTableName(),tabElem->GetSchemaName(),wxT(""));
+			if(tmp.length()>0)
+				alterTableScript+=tmp;
+		}
+	}
+	return alterTableScript;
+}
+
+void TableScript::CreatingIndexes(wxString schemaName,CreateTableArray &createTableIndexes,AlterTableArray  &alterTableIndexes,DropTableArray   &dropTableIndexes)
+{
+	for(size_t i=0; i<this->tableDiffList.GetCount();i++)
+	{
+		TableElement *tabElem = this->tableDiffList.Item(i);
+		wxString schName = tabElem->GetSchemaName();
+		wxString tabName = tabElem->GetTableName();
+
+		// schema is there, but table needs to be created
+		if(tabElem->GetMetaType() == CRTTABLE && tabElem->GetSchemaName()==schemaName)
+			createTableIndexes.Add(i);
+		else if(tabElem->GetMetaType() == ALTERTABLE && tabElem->GetSchemaName()==schemaName)
+			alterTableIndexes.Add(i);
+		else if(tabElem->GetMetaType() == DROPTABLE && tabElem->GetSchemaName()==schemaName)
+			dropTableIndexes.Add(i);
+	}
+}
+wxString TableScript::GenerateCreateFkScripts(wxString schemaName)
+{
+	wxString createFkScripts,tmp;
+	// going again to fetch fk's
+	for(size_t i=0; i<this->tableDiffList.GetCount();i++)
+	{
+		TableElement *tabElem = this->tableDiffList.Item(i);
+		wxString schName = tabElem->GetSchemaName();
+		
+		if(tabElem->GetMetaType() == CRTTABLE && tabElem->GetSchemaName() == schemaName)
+		{
+			tmp=this->fkScript->GenerateCreateScript(tabElem->GetTableName(),tabElem->GetSchemaName())+wxT("\n");
+			if(tmp.length()>0)
+				createFkScripts+=tmp;
+		}
+	}
+	return createFkScripts;
+}
+
+wxString TableScript::GenerateAlterFkScripts(wxString schemaName)
+{
+	wxString alterFkScripts,tmp;
+	// dropping fk
+	for(size_t i=0; i<this->tableDiffList.GetCount();i++)
+	{
+		TableElement *tabElem = this->tableDiffList.Item(i);
+		wxString schName = tabElem->GetSchemaName();
+
+		if(tabElem->GetMetaType() == ALTERTABLE && tabElem->GetSchemaName() == schemaName)
+		{
+			tmp=this->fkScript->GenerateAlterScript(tabElem->GetTableName(),tabElem->GetSchemaName(),wxT("DROP"))+wxT("\n");
+			if(tmp.length()>0)
+				alterFkScripts+=tmp;
+		}
+	}
+	// creating fk
+	for(size_t i=0; i<this->tableDiffList.GetCount();i++)
+	{
+		TableElement *tabElem = this->tableDiffList.Item(i);
+		wxString schName = tabElem->GetSchemaName();
+		
+		if(tabElem->GetMetaType() == CRTTABLE && tabElem->GetSchemaName() == schemaName)
+		{
+			tmp=this->fkScript->GenerateCreateScript(tabElem->GetTableName(),tabElem->GetSchemaName())+wxT("\n");
+			if(tmp.length()>0)
+				alterFkScripts+=tmp;
+		}
+	
+	}
+	// adding/altering fk
+	for(size_t i=0; i<this->tableDiffList.GetCount();i++)
+	{
+		TableElement *tabElem = this->tableDiffList.Item(i);
+		wxString schName = tabElem->GetSchemaName();
+
+		if(tabElem->GetMetaType() == ALTERTABLE && tabElem->GetSchemaName() == schemaName)
+		{
+			tmp=this->fkScript->GenerateAlterScript(tabElem->GetTableName(),tabElem->GetSchemaName(),wxT(""))+wxT("\n");
+			if(tmp.length()>0)
+				alterFkScripts+=tmp;
+		}
+	}
+	return alterFkScripts;
+}
+wxString TableScript::GenerateDropScript(wxString schemaName)
+{
+	wxString dropTableScript,tmp;
+	for(size_t i=0; i<this->tableDiffList.GetCount();i++)
+	{
+		TableElement *tabElem = this->tableDiffList.Item(i);
+		wxString schName = tabElem->GetSchemaName();
+		
+		if(tabElem->GetMetaType() == DROPTABLE && tabElem->GetSchemaName() == schemaName)
+		{
+			tmp=this->DropTableScript(tabElem->GetTableName(),tabElem->GetSchemaName());
+			if(tmp.length()>0)
+				dropTableScript+=tmp;
+
+			dropTableScript+=tabElem->GetScript(); // getting the table name
+		}
+	}
+	return dropTableScript;
+}
+wxString TableScript::CreateTableScript(wxString tableName,wxString schemaName)
+{
+	wxString createTableScript,tmp;
+
+	createTableScript+=wxT("(\n");
+	tmp+=this->columnScript->GenerateCreateScript(tableName,schemaName);
+	if(tmp.length()>0)
+	{
+		createTableScript+=tmp;
+		createTableScript+=wxT("\n");
+	}
+	tmp=this->pkScript->GenerateCreateScript(tableName,schemaName);
+	if(tmp.length()>0)
+	{
+		createTableScript.RemoveLast();
+		createTableScript+=wxT(",");
+
+		createTableScript+=tmp;
+		createTableScript+=wxT("\n");
+	}
+	tmp=this->uniqueScript->GenerateCreateScript(tableName,schemaName);
+	if(tmp.length()>0)
+	{
+		createTableScript.RemoveLast();
+		createTableScript+=wxT(",");
+
+		createTableScript+=tmp;
+		createTableScript+=wxT("\n");
+	}
+	createTableScript+=wxT(")\n WITH ( \n OIDS=FALSE\n );\n");
+	if(schemaName==wxT("public"))
+		createTableScript+=wxT(" ALTER TABLE \"")+ tableName+ wxT("\" OWNER TO postgres; ")+wxT("\n");
+	else
+		createTableScript+=wxT(" ALTER TABLE \"")+ schemaName+wxT("\".\"")+tableName+ wxT("\" OWNER TO postgres; ")+wxT("\n");
+	
+	tmp=this->indexScript->GenerateCreateScript(tableName,schemaName)+wxT("\n");
+	if(tmp.length()>0)
+	{
+		createTableScript+=tmp;
+		createTableScript+=wxT("\n");
+	}
+	tmp.Remove(0);
+	
+	return createTableScript;
+}
+wxString TableScript::AlterTableScript(wxString tableName,wxString schemaName,wxString ObjType)
+{
+	wxString alterTableScript,tmp;
+	tmp=this->columnScript->GenerateAlterScript(tableName,schemaName,this->GetPkScript(),
+																	this->GetFkScript(),
+																	this->GetIndexScript(),
+																	this->GetUniqueScript(),
+																	this->GetViewScript(),ObjType);
+	if(tmp.length()>0)
+	{
+		alterTableScript+=tmp;
+		alterTableScript+=wxT("\n");
+	}
+	tmp=this->pkScript->GenerateAlterScript(tableName,schemaName,this->GetFkScript(),ObjType);
+	if(tmp.length()>0)
+	{
+		alterTableScript+=tmp;
+		alterTableScript+=wxT("\n");
+	}
+	tmp=this->uniqueScript->GenerateAlterScript(tableName,schemaName,this->GetFkScript(),ObjType);
+	if(tmp.length()>0)
+	{
+		alterTableScript+=tmp;
+		alterTableScript+=wxT("\n");
+	}
+	tmp=this->indexScript->GenerateAlterScript(tableName,schemaName,ObjType);
+	if(tmp.length()>0)
+	{
+		alterTableScript+=tmp;
+		alterTableScript+=wxT("\n");
+	}
+	return alterTableScript;
+}
+wxString TableScript::DropTableScript(wxString tableName,wxString schemaName)
+{
+	wxString dropTableScript,tmp;
+
+	dropTableScript+=wxT("\n");
+	tmp+=this->columnScript->GenerateDropScript(tableName,schemaName,this->GetPkScript(),
+																	this->GetFkScript(),
+																	this->GetIndexScript(),
+																	this->GetUniqueScript(),
+																	this->GetViewScript());
+	if(tmp.length()>0)
+	{
+		dropTableScript+=tmp;
+		dropTableScript+=wxT("\n");
+	}
+	tmp=this->pkScript->GenerateDropScript(tableName,schemaName,this->GetFkScript());
+	if(tmp.length()>0)
+	{
+		dropTableScript+=tmp;
+		dropTableScript+=wxT("\n");
+	}
+	tmp=this->fkScript->GenerateDropScript(tableName,schemaName);
+	if(tmp.length()>0)
+	{
+		dropTableScript+=tmp;
+		dropTableScript+=wxT("\n");
+	}
+	tmp=this->uniqueScript->GenerateDropScript(tableName,schemaName,this->GetFkScript());
+	if(tmp.length()>0)
+	{
+		dropTableScript+=tmp;
+		dropTableScript+=wxT("\n");
+	}
+	tmp=this->indexScript->GenerateDropScript(tableName,schemaName)+wxT("\n");
+	if(tmp.length()>0)
+	{
+		dropTableScript+=tmp;
+		dropTableScript+=wxT("\n");
+	}
+	return dropTableScript;
+}
+void TableScript::AddDiffElement(TableElement * de)
+{
+	this->tableDiffList.Add(de);
+}
+bool TableScript::ShowDiff(pgObject * selObj, wxGrid * grid,bool bSync)
+{
+	wxString selTableName = selObj->GetName();
+	wxString selSchemaName = selObj->GetSchema()->GetName();
+	bool exist=false;
+	
+	for(size_t i=0; i<this->tableDiffList.GetCount();i++)
+	{
+		TableElement *tabElem = this->tableDiffList.Item(i);
+		if(tabElem->GetMetaType()==ALTERTABLE && 
+			tabElem->GetTableName()==selTableName &&
+			tabElem->GetSchemaName()==selSchemaName )
+		{
+			exist = ProcessDiff(tabElem->GetTableName(),tabElem->GetSchemaName(),grid,bSync);
+			break;
+		}
+	}
+	if(exist)
+		return true;
+	else
+		return false;
+}
+bool TableScript::ProcessDiff(wxString tabName ,wxString schemaName, wxGrid *grid,bool Sync)
+{
+	bool pkDiff=false,fkDiff=false,uniqueDiff=false,indexDiff=false;
+	bool bcolAddCount=false,bcolRemCount=false,altColDiff=false;
+	int colAddCount=0,colRemCount=0,fkAddCount=0,fkRemCount=0,uniAddCount=0,uniRemCount=0,indAddCount=0,indRemCount=0;
+	wxString constDiffDesc,colDiffDesc,dTypeDiffDesc,uniqueDiffDesc,indexDiffDesc;
+
+	// starting with blank
+	grid->SetCellValue(0,0,_T(""));
+	grid->SetCellValue(1,0,_T(""));
+	grid->SetCellValue(2,0,_T(""));
+	grid->SetCellValue(3,0,_T(""));
+	grid->SetCellValue(4,0,_T(""));
+	grid->SetCellValue(0,1,_T(""));
+	grid->SetCellValue(1,1,_T(""));
+	grid->SetCellValue(2,1,_T(""));
+	grid->SetCellValue(3,1,_T(""));
+	grid->SetCellValue(4,1,_T(""));
+
+	if(!Sync) // if not sync yet
+	{
+		// processing columns and data type difference
+		for(size_t i=0; i<this->GetColumnScript()->GetColumnList().GetCount(); i++)
+		{
+			ColumnElement * colElem = this->GetColumnScript()->GetColumnList().Item(i);
+			if((colElem->GetMetaType()==ALTERCOLUMN ||colElem->GetMetaType()==ADDCOLUMN ||colElem->GetMetaType()==DROPCOLUMN)&& 
+				colElem->GetTableName()==tabName &&  colElem->GetSchemaName()==schemaName )
+			{
+				if(colElem->GetMetaType()==ALTERCOLUMN) 
+				{
+					altColDiff=true;
+					if(((AlterColumn*)colElem)->IsTypChange())
+					{
+						dTypeDiffDesc+=((AlterColumn*)colElem)->GetDestDataType()+wxT("=>")+((AlterColumn*)colElem)->GetSrcDataType();
+					}
+				}
+				else
+				{
+					if(colElem->GetMetaType()==ADDCOLUMN)
+					{
+						bcolAddCount=true;
+						++colAddCount;
+					}
+					else
+					{
+						bcolRemCount=true;
+						++colRemCount;
+					}
+				}
+			}
+		}
+		
+		constDiffDesc+=wxT("FK:");
+		// processing constraints
+		for(size_t i=0; i<this->GetPkScript()->GetPkList().GetCount(); i++)
+		{
+			// not checking alter case for the time being
+			PkElement * pkElem = this->GetPkScript()->GetPkList().Item(i);
+			if((pkElem->GetMetaType() == ADDPK ||	pkElem->GetMetaType() == DROPPK) && 
+				pkElem->GetTableName() == tabName && pkElem->GetSchemaName() == schemaName )
+			{
+				pkDiff=true;
+				if(pkElem->GetMetaType() == ADDPK)
+					constDiffDesc+=wxT("PK Added");
+				if(pkElem->GetMetaType() == DROPPK)
+					constDiffDesc+=wxT("PK Dropped");
+				if(pkElem->GetMetaType() == ALTERPK)
+					constDiffDesc+=wxT("PK Column Changed");
+			}
+		}
+		
+		for(size_t i=0; i<this->GetFkScript()->GetFkList().GetCount();i++)
+		{
+			FkElement * fkElem = this->GetFkScript()->GetFkList().Item(i);
+			// not checking alter case for the time being
+			if((fkElem->GetMetaType() == ADDFK ||fkElem->GetMetaType() == DROPFK) && 
+				fkElem->GetTableName() == tabName && fkElem->GetSchemaName() == schemaName )
+			{
+				fkDiff=true; 
+				if(fkElem->GetMetaType()==ADDFK)
+					++fkAddCount;
+				else if(fkElem->GetMetaType()==DROPFK)
+					++fkRemCount;
+			}
+		}
+		for(size_t i=0; i<this->GetUniqueScript()->GetUniqueList().GetCount();i++)
+		{
+			// not checking alter case for the time being
+			UniqueElement * uniElem = this->GetUniqueScript()->GetUniqueList().Item(i);
+			if(( uniElem->GetMetaType() == ADDUNIQUE ||	uniElem->GetMetaType() == DROPUNIQUE) && 
+				uniElem->GetTableName() == tabName && uniElem->GetSchemaName() == schemaName )
+			{
+				uniqueDiff=true; 
+				if(uniElem->GetMetaType()==ADDUNIQUE)
+					++uniAddCount;
+				else if(uniElem->GetMetaType()==DROPUNIQUE)
+					++uniRemCount;
+			}
+		}
+		for(size_t i=0; i<this->GetIndexScript()->GetIndexList().GetCount();i++)
+		{
+			IndexElement * indElem = this->GetIndexScript()->GetIndexList().Item(i);
+			// not checking alter case for the time being
+			if((indElem->GetMetaType() == ADDINDEX ||	indElem->GetMetaType() == DROPINDEX ) && 
+				indElem->GetTableName() == tabName && indElem->GetSchemaName() == schemaName )
+			{
+				indexDiff=true; 
+				if(indElem->GetMetaType()==ADDINDEX)
+					++indAddCount;
+				else if(indElem->GetMetaType()==DROPINDEX)
+					++indRemCount;
+			}
+		}
+		// UI changes
+		//------------------------------------------------------------------------------------------------------
+		if(bcolAddCount || bcolRemCount)
+		{
+			wxString aCount,rCount;
+			aCount<<colAddCount;
+			rCount<<colRemCount;
+			colDiffDesc+=wxT("Added(")+aCount+wxT("), Removed(")+rCount+wxT(")");;
+			grid->SetCellValue(0,1,colDiffDesc);
+			grid->SetCellValue(0,0,_T("Yes"));
+			
+		}
+		else
+			grid->SetCellValue(0,0,_T("No"));
+		if(altColDiff)
+		{
+			grid->SetCellValue(1,0,_T("Yes"));
+			grid->SetCellValue(1,1,dTypeDiffDesc);
+		}
+		else
+			grid->SetCellValue(1,0,_T("No"));
+
+		// change at constraints level
+		if(pkDiff || fkDiff)
+		{
+			grid->SetCellValue(2,0,_T("Yes"));
+
+			if(fkDiff)
+			{
+				wxString aCount,rCount;
+				aCount<<fkAddCount;
+				rCount<<fkRemCount;
+				constDiffDesc+=wxT(",FK:Added(")+aCount+wxT("), Removed(")+rCount+wxT(")");
+			}
+
+			grid->SetCellValue(2,1,constDiffDesc);
+		}
+		else
+			grid->SetCellValue(2,0,_T("No"));
+
+		if(uniqueDiff)
+		{
+			grid->SetCellValue(3,0,_T("Yes"));
+			
+			wxString aCount,rCount;
+			aCount<<uniAddCount;
+			rCount<<uniRemCount;
+			uniqueDiffDesc+=wxT("Added(")+aCount+wxT("), Removed(")+rCount+wxT(")");
+			grid->SetCellValue(3,1,uniqueDiffDesc);
+		}
+		else
+			grid->SetCellValue(3,0,_T("No"));
+
+		if(indexDiff)
+		{
+			grid->SetCellValue(4,0,_T("Yes"));
+			
+			wxString aCount,rCount;
+			aCount<<indAddCount;
+			rCount<<indRemCount;
+			indexDiffDesc+=wxT("Added(")+aCount+wxT(") ,Removed(")+rCount+wxT(")");;
+			grid->SetCellValue(4,1,indexDiffDesc);
+		}
+		else
+			grid->SetCellValue(4,0,_T("No"));
+
+		if(pkDiff || fkDiff || 
+			uniqueDiff || indexDiff  || altColDiff || bcolAddCount || bcolRemCount)
+			return true;
+		//------------------------------------------------------------------------------------------------------------
+		// re-initializing
+		pkDiff=false;
+		fkDiff=false;
+		uniqueDiff=false;
+		indexDiff=false;
+
+	}
+	return false;
+}
diff --git a/pgadmin/sv/svUniqueDiff.cpp b/pgadmin/sv/svUniqueDiff.cpp
new file mode 100644
index 0000000..50735e5
--- /dev/null
+++ b/pgadmin/sv/svUniqueDiff.cpp
@@ -0,0 +1,247 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svUniqueDiff.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svUniqueDiff.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "sv/svUniqueDiff.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svDropUnique.h"
+#include "sv/svDropFk.h"
+#include "sv/svAlterUnique.h"
+
+bool UniqueDiff::GenStructuralDiff(DiffObject * trgUkc,ctlTree * src, ctlTree * trg,wxTreeItemId dummyId,TableScript * tabScr)
+{
+	
+	UniqueDiff * trgU = (UniqueDiff*)trgUkc;
+	pgUnique * pgu = trgU->GetUnique();
+	pgUnique * srcUni = (pgUnique*)this->GetObject();
+
+	// initializing columns
+	srcUni->ReadUniqueColumnInfo();
+	pgu->ReadUniqueColumnInfo();
+
+	
+	/*
+	If drop case not found, then the target unique has to be dropped and then added, and dropped needs dependency checking
+	*/
+	int obj = tabScr->GetUniqueScript()->SearchObject(pgu->GetTable()->GetName(),pgu->GetName(),DROPUNIQUE,pgu->GetSchema()->GetName());
+	if(obj==wxNOT_FOUND) // if the drop pk is not already entered by drop column
+	{
+		wxString name = srcUni->GetName();
+		if(srcUni->GetIndexType()!=pgu->GetIndexType() ||
+		srcUni->GetIsPrimary()!=pgu->GetIsPrimary() || 
+		srcUni->GetColumns()!=pgu->GetColumns())
+		{
+			AlterUnique * alterUnique = new AlterUnique(this);
+
+			// showing present elements @ target
+			////////////////////////////////////
+			trg->SetItemImage(pgu->GetId(),svImages.IMG_UNIQUE_CHG);
+			wxTreeItemId id = trg->GetItemParent(pgu->GetId());
+			trg->SetItemImage(id,svImages.IMG_CONSTRAINTS_CHG);
+			/////////////////////////////////////
+
+			// checking dependency and adding required dependent obj to drop this obj
+			DependentObjArray depList;
+			wxString where;
+			DiffObject::GetDependents(pgu,depList,where);
+			
+			if(!depList.IsEmpty()) // if the obj to be dropped has some dependents
+			{
+				int depIndex;
+				for(size_t i=0; i<depList.GetCount(); i++)
+				{
+					DependencyObj * dobj= (DependencyObj*)depList.Item(i);
+				
+					if(!dobj->tableName) // tableName is empty when unique is auto type
+						dobj->tableName = pgu->GetTable()->GetName();
+					
+					if(dobj->objTypeName == wxT("Foreign Key"))
+					{
+						// already there 
+						depIndex = tabScr->GetFkScript()->SearchObject(dobj->tableName,dobj->objName,DROPFK,dobj->schemaName);
+						if(depIndex == wxNOT_FOUND) 
+						{
+							// create a drop obj for dependent and add to list
+							FkElement * dropDependent = new DropFk(dobj->tableName,dobj->objName,dobj->schemaName);
+							((DropFk*)dropDependent)->GenerateScript();
+							tabScr->GetFkScript()->AddDiffElement(dropDependent);
+							
+							// getting the index of the added obj
+							depIndex = tabScr->GetFkScript()->SearchObject(dobj->tableName,dobj->objName,DROPFK,dobj->schemaName); 
+							if(depIndex !=wxNOT_FOUND) // this would always be true, just checking
+								alterUnique->iSetUniqueDepFkId(depIndex); // binding the dependent and non-dependent
+						}
+						else
+						{
+							; // do nothing as the columns would take care of the dependents
+						}
+					}
+				}
+			}
+			
+			((AlterUnique*)alterUnique)->setAlterCase(wxT("Overwrite"));
+			((AlterUnique*)alterUnique)->GenerateScript();
+			tabScr->GetUniqueScript()->AddDiffElement(alterUnique);
+			return true;
+		}
+	}
+	else 
+	{
+		/* if the drop pk is already in the list, this is a special case in because that shows
+		the column is being dropped along with the attached pk,but the new added pk has the same name
+		so no need to drop it again.
+		*/
+		AlterUnique * alterUnique = new AlterUnique(this);
+		((AlterUnique*)alterUnique)->setAlterCase(wxT("Add"));
+		((AlterUnique*)alterUnique)->GenerateScript();
+		tabScr->GetUniqueScript()->AddDiffElement(alterUnique);
+	}
+	return false;
+}
+///////////////////////////////////////////////////////////
+
+wxString UniqueScript::GenerateCreateScript(wxString tableName,wxString schemaName)
+{
+	wxString createUniqueScript;
+	for(size_t i=0; i<this->uniqueDiffList.GetCount();i++)
+	{
+		UniqueElement *uniElem = this->uniqueDiffList.Item(i);
+		if(uniElem->GetMetaType() == CRTUNIQUE && 
+			uniElem->GetTableName() == tableName &&
+			uniElem->GetSchemaName() == schemaName)
+		{
+			createUniqueScript+=uniElem->GetScript();
+			createUniqueScript+=wxT(",");
+		}
+	}
+	createUniqueScript.RemoveLast();
+	return createUniqueScript;
+}
+wxString UniqueScript::GenerateAlterScript(wxString tableName,wxString schemaName,FkScript * fkScr,wxString ObjType)
+{
+	int SearchMetaType;
+	if(ObjType == wxT("DROP")) // fetch only drop elements
+		SearchMetaType = DROPUNIQUE;
+	else
+		SearchMetaType = ADDUNIQUE; 
+
+	wxString alterUniqueScript,tmp;
+	for(size_t i=0; i<this->uniqueDiffList.GetCount();i++)
+	{
+		UniqueElement *uniElem = this->uniqueDiffList.Item(i);
+		if((uniElem->GetMetaType() == SearchMetaType ||uniElem->GetMetaType() == ALTERUNIQUE)&& 
+			uniElem->GetTableName() == tableName && 
+			uniElem->GetSchemaName() == schemaName)
+		{
+			if(uniElem->GetMetaType()==DROPUNIQUE &&
+				!uniElem->IsAlreadyApplied()) 
+			{
+				DropUnique * dropUnique = (DropUnique*)uniElem;
+				
+				if(dropUnique->HasDepFk()) // col has fk dependent
+				{
+					for(size_t i=0; i< dropUnique->GetDependentFkList().GetCount(); i++)
+					{
+						int fkId = dropUnique->GetDependentFkList().Item(i);
+						// fetch the foriegn key from list
+						FkElement * fk = fkScr->GetFkList().Item(fkId);
+						if(!((DropFk*)fk)->IsAlreadyApplied()) // checking if the fk script is already included
+						{
+							tmp = ((DropFk*)fk)->GetScript(); // generating the drop script
+							if(tmp.length()>0)
+							alterUniqueScript+=tmp;
+						}
+					}
+				}
+				// after dependency checking add the drop script
+				alterUniqueScript+=uniElem->GetScript();
+			}
+			else if(uniElem->GetMetaType()==ADDUNIQUE)
+			{
+				alterUniqueScript+=uniElem->GetScript();
+			}
+			else if(uniElem->GetMetaType()==ALTERUNIQUE)
+			{
+				alterUniqueScript+=uniElem->GetScript();
+			}
+		}
+	}
+	return alterUniqueScript;
+}
+
+wxString UniqueScript::GenerateDropScript(wxString tableName,wxString schemaName,FkScript * fkScr)
+{
+	wxString dropUniqueScript,tmp;
+	for(size_t i=0; i<this->uniqueDiffList.GetCount();i++)
+	{
+		UniqueElement *uniElem = this->uniqueDiffList.Item(i);
+		if((uniElem->GetMetaType()== DROPUNIQUE )&& 
+			uniElem->GetTableName() == tableName && 
+			uniElem->GetSchemaName() == schemaName)
+		{
+			if(!((DropUnique*)uniElem)->IsAlreadyApplied()) 
+			{
+				DropUnique * dropUnique = (DropUnique*)uniElem;
+				
+				if(dropUnique->HasDepFk()) // col has fk dependent
+				{
+					for(size_t i=0; i< dropUnique->GetDependentFkList().GetCount(); i++)
+					{
+						int fkId = dropUnique->GetDependentFkList().Item(i);
+						// fetch the foriegn key from list
+						FkElement * fk = fkScr->GetFkList().Item(fkId);
+						if(!((DropFk*)fk)->IsAlreadyApplied()) // checking if the fk script is already included
+						{
+							tmp = ((DropFk*)fk)->GetScript(); // generating the drop script
+							if(tmp.length()>0)
+							dropUniqueScript+=tmp;
+						}
+					}
+				}
+				// after dependency checking add the drop script
+				dropUniqueScript+=uniElem->GetScript();
+			}
+		}
+	}
+	return dropUniqueScript;
+}
+
+void UniqueScript::AddDiffElement(UniqueElement * de)
+{
+	this->uniqueDiffList.Add(de);
+}
+int UniqueScript::SearchObject(wxString tableName,wxString objName,int metaType,wxString schemaName)
+{
+	if(schemaName.length()==0)
+		schemaName=wxT("public");
+
+	int index=wxNOT_FOUND;
+	for(size_t i=0; i<uniqueDiffList.GetCount();i++)
+	{
+		UniqueElement * de = uniqueDiffList.Item(i);
+		if(de->GetMetaType() == metaType)
+		{
+			if(metaType == DROPUNIQUE) // searching for dropped unique object
+			{
+				DropUnique * dunique = (DropUnique*)de;
+				if( dunique->GetSchemaName() == schemaName && 
+					dunique->GetTableName() == tableName &&
+					dunique->GetUniqueName() == objName )
+				{
+					index = uniqueDiffList.Index(de);
+					break;
+				}
+			}
+		}
+	}
+	return index;
+}
diff --git a/pgadmin/sv/svViewDiff.cpp b/pgadmin/sv/svViewDiff.cpp
new file mode 100644
index 0000000..df45d24
--- /dev/null
+++ b/pgadmin/sv/svViewDiff.cpp
@@ -0,0 +1,416 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id: svViewDiff.cpp 8189 2010-02-25 22:10:21Z dpage $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// svViewDiff.cpp - 
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include "sv/svViewDiff.h"
+#include "sv/svColumnDiff.h"
+#include "sv/svRuleDiff.h"
+#include "sv/svDiffSystem.h"
+#include "sv/svDiffElement.h"
+#include "sv/svDropView.h"
+
+
+ViewDiff::ViewDiff(pgObject * view):DiffObject(view)
+{	
+	viewhandle = (pgView *)view;
+	viewChangesExist = false;
+}
+
+void ViewDiff::LoadDiffSystemObjects(wxTreeItemId viewRoot, ctlTree * tree)
+{
+	wxTreeItemId vcolumnRoot,vcolumnList,vruleRoot,vruleList;
+	wxCookieType vcolRootCookie,vcolListCookie,vruleListCookie;
+
+	if(tree->HasChildren(viewRoot))
+	{
+		vcolumnRoot = tree->GetFirstChild(viewRoot,vcolRootCookie);
+		vruleRoot = tree->GetNextSibling(vcolumnRoot);
+		// checking for view columns
+		if(tree->HasChildren(vcolumnRoot))
+		{
+			vcolumnList = tree->GetFirstChild(vcolumnRoot,vcolListCookie);
+			while(vcolumnList)
+			{
+				pgObject * column = tree->GetObject(vcolumnList);
+				ColumnDiff * dviewCol = new ColumnDiff(column);
+				this->colObjList.Add(dviewCol);
+				vcolumnList = tree->GetNextChild(vcolumnRoot,vcolListCookie);
+			}
+		}
+		// checking for view rule
+		if(tree->HasChildren(vruleRoot))
+		{ 
+			vruleList = tree->GetFirstChild(vruleRoot,vruleListCookie);
+			while(vruleList)
+			{
+				pgObject * rule = tree->GetObject(vruleList);
+				RuleDiff * drule = new RuleDiff(rule);
+				this->ruleObjList.Add(drule);
+				vruleList = tree->GetNextChild(vruleRoot,vruleListCookie);
+			}
+		}
+	}
+}
+bool ViewDiff::GenStructuralDiff(DiffObject * trgV,ctlTree * src, ctlTree * trg, wxTreeItemId dummyViewId,ViewScript * viewScr)
+{
+	wxTreeItemId dummyColumnsId=NULL;
+	wxTreeItemId dummyRulesId=NULL;
+
+	if(!trgV && !trg->HasChildren(dummyViewId))  // add the whole schema sub tree
+	{
+		// showing columns root
+		trg->AppendItem(dummyViewId,wxT("Columns (0)"),svImages.IMG_COLUMNS,-1,NULL);
+		trg->AppendItem(dummyViewId,wxT("Rules (0)"),svImages.IMG_RULES_CHG,-1,NULL);
+	}
+
+	wxCookieType cookie;
+	if(!trgV)
+	{
+		dummyColumnsId = trg->GetFirstChild(dummyViewId,cookie);
+		dummyRulesId = trg->GetNextChild(dummyViewId,cookie);
+	}
+	
+	GenStrColumnDiff(trgV,src,trg,dummyColumnsId,viewScr);
+	GenStrRuleDiff(trgV,src,trg,dummyRulesId,viewScr);
+	return viewChangesExist;
+
+}
+void ViewDiff::GenStrColumnDiff(DiffObject * trgV,ctlTree* src, ctlTree * trg,wxTreeItemId dummyColumnsId,ViewScript * viewScr)
+{
+	ViewDiff * trgView = (ViewDiff *)trgV;
+	// searching for the schema objects not present in trg
+	for(size_t i=0; i < (this->colObjList.GetCount()) ; i++)
+	{
+		ColumnDiff *srcColumn = (ColumnDiff *)(this->colObjList.Item(i)); 
+		wxString colName  = srcColumn->GetColumn()->GetName();
+		
+		if(!trgView ||  // trgTable would be null when table is not present at the target 
+			!trgView->IsColPresent(colName)) // if schema is present but schema objects are missing in target
+		{ 
+			pgColumn* pgc = srcColumn->GetColumn();
+			viewChangesExist=true;
+			//////////////////////////////////////////////////////////////////////////////////////////////
+			// performing UI changes, 
+			// showing its missing in target
+			wxTreeItemId columnsId;
+			columnsId = dummyColumnsId;
+			if(!trgV)  // adding the whole schema sub tree
+			{
+
+				trg->AppendItem(columnsId,colName,svImages.IMG_COLUMN_PRES,-1,NULL);
+				trg->SetItemImage(columnsId,svImages.IMG_COLUMNS_CHG);
+				trg->SortChildren(columnsId);
+			}
+			else
+			{
+				wxTreeItemId viewId = trgView->GetObject()->GetId();
+				wxCookieType cookie;
+				wxTreeItemId columnsId = trg->GetFirstChild(viewId,cookie);
+				trg->AppendItem(columnsId,colName,svImages.IMG_COLUMN_PRES,-1,NULL);
+				trg->SetItemImage(columnsId,svImages.IMG_COLUMNS_CHG);  
+				trg->SortChildren(columnsId);
+			}
+			////////////////////////////////////////////////////////////////////////////////////////////
+		}
+		else // column got matched
+		{
+			//ColumnDiff * trgColumn = (ColumnDiff*)trgView->FindColObj(colName);
+
+		}
+	}
+	// searching for the column objects not present in source
+	if(trgView)
+	{
+		for(size_t i=0; i < (trgView->GetColumnObjList().GetCount()) ; i++)
+		{
+			ColumnDiff *trgColumn = (ColumnDiff *)(trgView->GetColumnObjList()).Item(i); 
+	
+			wxString colName  = trgColumn->GetColumn()->GetName();
+			if(!this->IsColPresent(colName)) 
+			{ 
+				pgColumn* pgc = trgColumn->GetColumn();
+				
+				viewChangesExist=true;
+				// performing UI changes
+
+				// showing present elements @ target
+				////////////////////////////////////
+				trg->SetItemImage(pgc->GetId(),svImages.IMG_COLUMN_MISS);
+				wxTreeItemId id = trg->GetItemParent(pgc->GetId());
+				trg->SetItemImage(id,svImages.IMG_COLUMNS_CHG);
+				/////////////////////////////////////
+			}
+		}
+	}
+}
+void ViewDiff::GenStrRuleDiff(DiffObject * trgV,ctlTree* src, ctlTree * trg,wxTreeItemId dummyRulesId,ViewScript * viewScr)
+{
+	ViewDiff * trgView = (ViewDiff *)trgV;
+	// searching for the schema objects not present in trg
+	for(size_t i=0; i < (this->ruleObjList.GetCount()) ; i++)
+	{
+		RuleDiff *srcRule = (RuleDiff *)(this->ruleObjList.Item(i)); 
+		wxString ruleName  = srcRule->GetRule()->GetName();
+		
+		if(!trgView ||  // trgTable would be null when table is not present at the target 
+			!trgView->IsRulePresent(ruleName)) // if schema is present but schema objects are missing in target
+		{ 
+			pgRule* pgr = srcRule->GetRule();
+			viewChangesExist=true;
+			//////////////////////////////////////////////////////////////////////////////////////////////
+			// performing UI changes, 
+			// showing its missing in target
+			wxTreeItemId rulesId;
+			rulesId = dummyRulesId;
+			if(!trgV)  // adding the whole schema sub tree
+			{
+
+				trg->AppendItem(rulesId,ruleName,svImages.IMG_RULE_PRES,-1,NULL);
+				trg->SetItemImage(rulesId,svImages.IMG_RULES_CHG);
+				trg->SortChildren(rulesId);
+			}
+			else
+			{
+				wxTreeItemId viewId = trgView->GetObject()->GetId();
+				wxCookieType cookie;
+				wxTreeItemId columnsId = trg->GetFirstChild(viewId,cookie);
+				wxTreeItemId rulesId = trg->GetNextSibling(columnsId);
+				trg->AppendItem(rulesId,ruleName,svImages.IMG_RULE_PRES,-1,NULL);
+				trg->SetItemImage(rulesId,svImages.IMG_RULES_CHG);  
+				trg->SortChildren(rulesId);
+			}
+			////////////////////////////////////////////////////////////////////////////////////////////
+		}
+		else // rule got matched
+		{
+			bool ruleChangesExist;
+			RuleDiff * trgRule = (RuleDiff*)trgView->FindRuleObj(ruleName);
+			ruleChangesExist = srcRule->GenStructuralDiff(trgRule,src,trg,NULL,viewScr->GetRuleScriptHandle());
+			if(ruleChangesExist)
+			{
+				this->viewChangesExist=true;
+				ruleChangesExist=false;
+			}
+		}
+	}
+	// searching for the column objects not present in source
+	if(trgView)
+	{
+		for(size_t i=0; i < (trgView->GetRuleObjList().GetCount()) ; i++)
+		{
+			RuleDiff *trgRule = (RuleDiff *)(trgView->GetRuleObjList()).Item(i); 
+	
+			wxString ruleName  = trgRule->GetRule()->GetName();
+			if(!this->IsColPresent(ruleName)) 
+			{ 
+				pgRule* pgr = trgRule->GetRule();
+				viewChangesExist=true;
+				// performing UI changes
+				// showing present elements @ target
+				////////////////////////////////////
+				trg->SetItemImage(pgr->GetId(),svImages.IMG_RULE_MISS);
+				wxTreeItemId id = trg->GetItemParent(pgr->GetId());
+				trg->SetItemImage(id,svImages.IMG_RULES_CHG);
+				/////////////////////////////////////
+			}
+		}
+	}
+}
+void ViewDiff::DropViewObject(DiffObject * trgV,ctlTree * src, ctlTree * trg,ViewScript * viewScr)
+{
+	// This would only change UI as the drop thing is already handled at the view level.
+	DropColumnObject(trgV,src,trg,viewScr);
+	DropRuleObject(trgV,src,trg,viewScr);
+}
+void ViewDiff::DropColumnObject(DiffObject * trgV,ctlTree * src, ctlTree * trg,ViewScript * viewScr)
+{
+	ViewDiff * trgView = (ViewDiff *)trgV;
+	for(size_t i=0; i < (trgView->GetColumnObjList().GetCount()) ; i++)
+	{
+		ColumnDiff *trgColumn = (ColumnDiff *)(trgView->GetColumnObjList()).Item(i); 
+		wxString colName  = trgColumn->GetColumn()->GetName();
+		pgColumn* pgc = trgColumn->GetColumn();
+
+		// performing UI changes
+		// showing drop elements @ target
+		////////////////////////////////////
+		trg->SetItemImage(pgc->GetId(),svImages.IMG_COLUMN_MISS);
+		wxTreeItemId id = trg->GetItemParent(pgc->GetId());
+		trg->SetItemImage(id,svImages.IMG_COLUMNS_CHG);
+		/////////////////////////////////////
+	}
+}
+void ViewDiff::DropRuleObject(DiffObject * trgV,ctlTree * src, ctlTree * trg,ViewScript * viewScr)
+{
+	ViewDiff * trgView = (ViewDiff *)trgV;
+	for(size_t i=0; i < (trgView->GetRuleObjList().GetCount()) ; i++)
+	{
+		RuleDiff *trgRule = (RuleDiff *)(trgView->GetRuleObjList()).Item(i); 
+		wxString ruleName  = trgRule->GetRule()->GetName();
+		pgRule* pgr = trgRule->GetRule();
+
+		// performing UI changes
+		// showing drop elements @ target
+		////////////////////////////////////
+		trg->SetItemImage(pgr->GetId(),svImages.IMG_RULE_MISS);
+		wxTreeItemId id = trg->GetItemParent(pgr->GetId());
+		trg->SetItemImage(id,svImages.IMG_RULES_CHG);
+		/////////////////////////////////////
+	}
+}
+
+bool ViewDiff::IsColPresent(wxString objname)
+{
+	
+	bool found = false;
+	ColumnDiff * col;
+	
+	for(size_t i =0 ; i < (this->colObjList.GetCount()) ; i++)
+	{
+	    col = (ColumnDiff*)(this->colObjList.Item(i));
+
+		if(col->GetObject()->GetName() == objname) 
+		{ 
+			found = true;
+			break;
+		}
+	}
+	return found;
+}
+DiffObject *ViewDiff::FindColObj(wxString objname)
+{
+
+	bool found = false;
+	ColumnDiff * col;
+	
+	for(size_t i =0 ; i< (this->colObjList.GetCount()) ; i++)
+	{
+	    col = (ColumnDiff*)(this->colObjList.Item(i));
+
+		if(col->GetObject()->GetName() == objname) 
+		{ 
+			return col;
+		}
+	}
+	return 0;
+}
+bool ViewDiff::IsRulePresent(wxString objname)
+{
+	
+	bool found = false;
+	RuleDiff * rule;
+	
+	for(size_t i =0 ; i < (this->ruleObjList.GetCount()) ; i++)
+	{
+	    rule = (RuleDiff*)(this->ruleObjList.Item(i));
+
+		if(rule->GetObject()->GetName() == objname) 
+		{ 
+			found = true;
+			break;
+		}
+	}
+	return found;
+}
+DiffObject *ViewDiff::FindRuleObj(wxString objname)
+{
+
+	bool found = false;
+	RuleDiff * rule;
+	
+	for(size_t i =0 ; i< (this->ruleObjList.GetCount()) ; i++)
+	{
+	    rule = (RuleDiff*)(this->ruleObjList.Item(i));
+
+		if(rule->GetObject()->GetName() == objname) 
+		{ 
+			return rule;
+		}
+	}
+	return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+void ViewScript::AddDiffElement(ViewElement * de)
+{
+	this->viewDiffList.Add(de);
+}
+void ViewScript::Initialize ()
+{
+	ruleScript = new RuleScript();
+}
+int ViewScript::SearchObject(wxString viewName,int metaType,wxString schemaName)
+{
+	if(schemaName.length()==0)
+		schemaName=wxT("public");
+
+	int index=wxNOT_FOUND;
+	for(size_t i=0; i<viewDiffList.GetCount();i++)
+	{
+		ViewElement * de = viewDiffList.Item(i);
+		wxString schName = de->GetSchemaName();
+		
+		if(de->GetMetaType() == metaType)
+		{
+			if(metaType == DROPVIEW) // searching for dropped view object
+			{
+				DropView * dview = (DropView*)de;
+				wxString oName = dview->GetViewName();
+				if( dview->GetSchemaName() == schemaName && 
+					dview->GetViewName() == viewName)
+				{
+					index = viewDiffList.Index(de);
+					break;
+				}
+			}
+		}
+	}
+	return index;
+}
+wxString ViewScript::GenerateCreateScript(wxString schemaName)
+{
+	wxString createViewScript,tmp;
+	for(size_t i=0; i<this->viewDiffList.GetCount();i++)
+	{
+		ViewElement *viewElem = this->viewDiffList.Item(i);
+		wxString schName = viewElem->GetSchemaName();
+		
+		if(viewElem->GetMetaType() == CRTVIEW && viewElem->GetSchemaName() == schemaName)
+		{
+			tmp=viewElem->GetScript(); // getting views
+			if(tmp.length()>0)
+				createViewScript+=tmp;
+		}
+	}
+	return createViewScript;
+}
+wxString ViewScript::GenerateDropScript(wxString schemaName)
+{
+	wxString dropViewScript,tmp;
+	for(size_t i=0; i<this->viewDiffList.GetCount();i++)
+	{
+		ViewElement *viewElem = this->viewDiffList.Item(i);
+		wxString schName = viewElem->GetSchemaName();
+		
+		if(viewElem->GetMetaType() == DROPVIEW && viewElem->GetSchemaName() == schemaName)
+		{
+			if(!viewElem->IsAlreadyApplied())
+			{
+				tmp=viewElem->GetScript(); // getting views
+				if(tmp.length()>0)
+					dropViewScript+=tmp;
+			}
+		}
+	}
+	return dropViewScript;
+}
+
