internal override string Drop(InterItemCommunication communication) { if (communication.TableToDeleteList.Contains(TableName)) { return(""); } return($"ALTER TABLE {TableName} DROP CONSTRAINT {Name}"); }
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}"); }
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); }
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()); }
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}"); } }
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}"); } }
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); }
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); }
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); }
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); }
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); }
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); }
internal virtual string Create(InterItemCommunication communication) { string options = GenerateOptions(); return($"CREATE {ElementType} {Name} {options}"); }
internal virtual string Drop(InterItemCommunication communication) { return($"DROP {ElementType} {(IfExists ? "IF EXISTS" : "")} {Name} {(Cascade ? "CASCADE" : "")}"); }
internal override string Alter(ItemComparable target, InterItemCommunication communication) { return(Drop(communication) + ";" + Environment.NewLine + Create(communication)); }
internal virtual string Alter(ItemComparable target, InterItemCommunication communication) { throw new NotImplementedException(); }
internal override string Create(InterItemCommunication communication) { return($"CREATE VIEW {Name} AS {Definition}"); }