コード例 #1
0
 internal override string Drop(InterItemCommunication communication)
 {
     if (communication.TableToDeleteList.Contains(TableName))
     {
         return("");
     }
     return($"ALTER TABLE {TableName} DROP CONSTRAINT {Name}");
 }
コード例 #2
0
 internal override string Create(InterItemCommunication communication)
 {
     if (Definition == "null")
     {
         return($"--Erreur sur définition de la clé étrangère {Key()}");
     }
     return($"ALTER TABLE {TableName} ADD CONSTRAINT {Name} {Definition}");
 }
コード例 #3
0
ファイル: Column.cs プロジェクト: yuxueliang/ComparePgsqlTool
 internal override string Drop(InterItemCommunication communication)
 {
     if (!communication.TableToDeleteList.Contains(TableName))
     {
         return($"ALTER TABLE {TableName} DROP COLUMN IF EXISTS {Name}");
     }
     //else : no need to remove a column from a table that will be deleted!
     return(string.Empty);
 }
コード例 #4
0
ファイル: Column.cs プロジェクト: yuxueliang/ComparePgsqlTool
        internal override string Alter(ItemComparable target, InterItemCommunication communication)
        {
            StringBuilder alter = new StringBuilder();

            AddTypeModification(alter, target);
            AddNullableModification(alter, target);
            AddDefaultModification(alter, target);
            AddIdentityGenerationModification(alter, target);
            return(alter.ToString());
        }
コード例 #5
0
 internal override string Drop(InterItemCommunication communication)
 {
     if (ElementType == Constants.COLUMN)
     {
         return($"REVOKE {AccessList} ({Name}) ON {Target} {TableName} FROM {User}");
     }
     else
     {
         return($"REVOKE {AccessList} ON {Target} {TableName} FROM {User}");
     }
 }
コード例 #6
0
 internal override string Create(InterItemCommunication communication)
 {
     if (ElementType == Constants.COLUMN)
     {
         return($"GRANT {AccessList} ({Name}) ON {Target} {TableName} TO {User}");
     }
     else
     {
         return($"GRANT {AccessList} ON {Target} {TableName} TO {User}");
     }
 }
コード例 #7
0
        internal override string Drop(InterItemCommunication communication)
        {
            string drop = "";

            if (UsedBy != "null")
            {
                drop  = "--!!!! ATTENTION This view is used by other views !" + Environment.NewLine;
                drop += "--" + UsedBy + Environment.NewLine;
            }
            drop += base.Drop(communication);
            return(drop);
        }
コード例 #8
0
        internal override string Drop(InterItemCommunication communication)
        {
            if (communication.TableToDeleteList.Contains(TableName))
            {
                return("");
            }

            string drop = "";

            if (Constraint != "null")
            {
                drop += "--Attention. This will delete linked foreign keys !" + Environment.NewLine;
                drop += $"ALTER TABLE ONLY {TableName} DROP CONSTRAINT IF EXISTS {Name} CASCADE;" + Environment.NewLine;
            }
            drop += base.Drop(communication);
            return(drop);
        }
コード例 #9
0
ファイル: Column.cs プロジェクト: yuxueliang/ComparePgsqlTool
        internal override string Create(InterItemCommunication communication)
        {
            string create = "";

            if (ElementType == "ARRAY")
            {
                create = "--!!! ARRAY : Double check !!!";
            }
            if (DefautValue.EndsWith($".{TableName}_{Name}_seq'::regclass)"))
            {
                ElementType = "SERIAL";
            }

            create += $"ALTER TABLE {TableName} ADD COLUMN {Name} {TypeStringFromElementType} {GenerateOptions()}";

            return(create);
        }
コード例 #10
0
        internal override string Alter(ItemComparable target, InterItemCommunication communication)
        {
            string alter = string.Empty;

            var optionsTarget = target.GenerateOptions();
            var options       = GenerateOptions();

            if (options != optionsTarget)
            {
                alter = $"CREATE ROLE {Name} {options};";
            }

            if (this["memberof"] != target["memberof"])
            {
                alter += GenerateMemberOfDifference(target);
            }
            return(alter);
        }
コード例 #11
0
        internal override string Alter(ItemComparable target, InterItemCommunication communication)
        {
            string alter          = "";
            var    goodTypeTarget = target as Index;

            if (Definition == "null")
            {
                return($"--Error on index definition {Key()}");
            }
            if (goodTypeTarget.Definition == "null")
            {
                return($"--Error on index definition {goodTypeTarget.Key()}");
            }
            alter  = Drop(communication);
            alter += ";" + Environment.NewLine;
            alter += Create(communication);

            return(alter);
        }
コード例 #12
0
        internal override string Create(InterItemCommunication communication)
        {
            if (Definition == "null")
            {
                return($"--Error on index definition {Key()}");
            }

            string create = Definition;

            create += ";" + Environment.NewLine;

            if (Constraint != "null")
            {
                if (PrimaryKey != "null")
                {
                    create += $"ALTER TABLE ONLY {TableName} ADD CONSTRAINT {Name} PRIMARY KEY USING INDEX {Name}";
                }
                else if (UniqueKey == "True")
                {
                    create += $"ALTER TABLE ONLY {TableName} ADD CONSTRAINT {Name} UNIQUE USING INDEX {Name}";
                }
            }
            return(create);
        }
コード例 #13
0
        internal virtual string Create(InterItemCommunication communication)
        {
            string options = GenerateOptions();

            return($"CREATE {ElementType} {Name} {options}");
        }
コード例 #14
0
 internal virtual string Drop(InterItemCommunication communication)
 {
     return($"DROP {ElementType} {(IfExists ? "IF EXISTS" : "")} {Name} {(Cascade ? "CASCADE" : "")}");
 }
コード例 #15
0
 internal override string Alter(ItemComparable target, InterItemCommunication communication)
 {
     return(Drop(communication) + ";" + Environment.NewLine + Create(communication));
 }
コード例 #16
0
 internal virtual string Alter(ItemComparable target, InterItemCommunication communication)
 {
     throw new NotImplementedException();
 }
コード例 #17
0
 internal override string Create(InterItemCommunication communication)
 {
     return($"CREATE VIEW {Name} AS {Definition}");
 }