public void RenameSchema(ISchemaStructure schema, string newname) { var sch = Schemata.FirstOrDefault(s => s.SchemaName == schema.SchemaName) as SchemaStructure; sch.SchemaName = newname; RunNameTransformation(new RenameSchemaTransform(schema.SchemaName, newname)); }
public void DropSchema(ISchemaStructure schema) { SchemaStructure s = Structure.FindOrCreateSchema(schema); AddOperation(new AlterOperation_DropSchema { OldObject = s }); }
public void RenameSchema(ISchemaStructure schema, string name) { SchemaStructure s = Structure.FindOrCreateSchema(schema); AddOperation(new AlterOperation_RenameSchema { OldObject = s, NewName = new NameWithSchema(name) }); }
public void CreateSchema(ISchemaStructure schema) { SchemaStructure s = new SchemaStructure(schema); AddOperation(new AlterOperation_CreateSchema { NewObject = s }); }
public SchemaStructure FindOrCreateSchema(ISchemaStructure schema) { var res = FindSchema(schema.SchemaName); if (res == null) { res = AddSchema(schema, false); } return(res); }
public SchemaStructure AddSchema(ISchemaStructure schema, bool reuseGroupId) { var newsch = new SchemaStructure(schema); if (!reuseGroupId) { newsch.GroupId = Guid.NewGuid().ToString(); } Schemata.Add(newsch); return(newsch); }
public string Generate(ISchemaStructure structure) { var typeSymbol = structure.TypeSymbol; var typeNamespace = SymbolTypeUtil.MergeContainingNamespaces(typeSymbol); var declaringTypes = SymbolTypeUtil.GetDeclaringTypesDownward(typeSymbol); var cbsb = new CurlyBracketStringBuilder(); cbsb.WriteLine("using System;") .WriteLine("using System.IO;"); // TODO: Handle fancier cases here cbsb.EnterBlock($"namespace {typeNamespace}"); foreach (var declaringType in declaringTypes) { cbsb.EnterBlock(SymbolTypeUtil.GetQualifiersAndNameFor(declaringType)); } cbsb.EnterBlock(SymbolTypeUtil.GetQualifiersAndNameFor(typeSymbol)); cbsb.EnterBlock("public void Write(EndianBinaryWriter ew)"); foreach (var member in structure.Members) { SchemaWriterGenerator.WriteMember_(cbsb, typeSymbol, member); } cbsb.ExitBlock(); // TODO: Handle fancier cases here // type cbsb.ExitBlock(); // parent types foreach (var declaringType in declaringTypes) { cbsb.ExitBlock(); } // namespace cbsb.ExitBlock(); var generatedCode = cbsb.ToString(); return(generatedCode); }
public void CreateSchema(ISchemaStructure schema) { AddSchema(schema, false); }
public void DropSchema(ISchemaStructure schema) { Schemata.RemoveIf(s => s.SchemaName == schema.SchemaName); }
public void ChangeSchema(ISchemaStructure ssrc, ISchemaStructure sdst) { var obj = (SchemaStructure)this.FindSchema(ssrc.SchemaName); obj.AssignFrom(sdst); }
public static void AlterDatabase(AlterPlan plan, DbObjectPairing pairing, DbDiffOptions opts) { var src = pairing.Source; var dst = pairing.Target; //var caps = proc.AlterCaps; // domains foreach (IDomainStructure dsrc in src.Domains) { IDomainStructure ddst = pairing.FindPair(dsrc); if (ddst == null) { plan.DropDomain(dsrc); } else if (!DbDiffTool.EqualDomains(dsrc, ddst, opts, true)) { if (DbDiffTool.EqualDomains(dsrc, ddst, opts, false)) { plan.RenameDomain(dsrc, ddst.FullName); } else { plan.ChangeDomain(dsrc, ddst); } } } foreach (IDomainStructure ddst in dst.Domains) { if (!pairing.IsPaired(ddst)) { plan.CreateDomain(ddst); } } // drop tables foreach (ITableStructure tsrc in new List <ITableStructure>(src.Tables)) { ITableStructure tdst = pairing.FindPair(tsrc); if (tdst == null) { plan.DropTable(tsrc); } } // change tables foreach (ITableStructure tsrc in new List <ITableStructure>(src.Tables)) { ITableStructure tdst = pairing.FindPair(tsrc); if (tdst == null) { continue; } if (!DbDiffTool.EqualTables(tsrc, tdst, opts, pairing)) { DbDiffTool.AlterTable(plan, tsrc, tdst, opts, pairing); } else { DbDiffTool.AlterFixedData(plan, tsrc, tdst, opts); } } // create tables foreach (ITableStructure tdst in dst.Tables) { if (!pairing.IsPaired(tdst)) { var script = DbDiffTool.AlterFixedData(null, tdst.FixedData, null, opts); plan.CreateTable(tdst, script); //if (script != null) plan.UpdateData(tdst.FullName, script); } } // specific objects foreach (ISpecificObjectStructure osrc in src.GetAllSpecificObjects()) { var repr = SpecificRepresentationAddonType.Instance.FindRepresentation(osrc.ObjectType); if (!repr.UseInSynchronization) { continue; } ISpecificObjectStructure odst = pairing.FindPair(osrc); if (odst == null) { plan.DropSpecificObject(osrc); //proc.DropSpecificObject(osrc); } else if (!DbDiffTool.EqualsSpecificObjects(osrc, odst, opts)) { DbDiffTool.AlterSpecificObject(osrc, odst, plan, opts, pairing); } } foreach (ISpecificObjectStructure odst in dst.GetAllSpecificObjects()) { var repr = SpecificRepresentationAddonType.Instance.FindRepresentation(odst.ObjectType); if (!repr.UseInSynchronization) { continue; } if (!pairing.IsPaired(odst)) { plan.CreateSpecificObject(odst); //proc.CreateSpecificObject(odst); } } foreach (ISchemaStructure ssrc in src.Schemata) { ISchemaStructure sdst = pairing.FindPair(ssrc); if (sdst == null) { plan.DropSchema(ssrc); } else if (ssrc.SchemaName != sdst.SchemaName) { plan.RenameSchema(ssrc, sdst.SchemaName); //if (caps.RenameSchema) proc.RenameSchema(ssrc, sdst.SchemaName); //else //{ // proc.DropSchema(ssrc); // proc.CreateSchema(sdst); //} } } foreach (ISchemaStructure sdst in dst.Schemata) { if (!pairing.IsPaired(sdst)) { plan.CreateSchema(sdst); } } var alteredOptions = GetDatabaseAlteredOptions(src, dst, opts); if (alteredOptions.Count > 0) { plan.ChangeDatabaseOptions(null, alteredOptions); } if (opts.SchemaMode == DbDiffSchemaMode.Ignore) { plan.RunNameTransformation(new SetSchemaNameTransformation(null)); } }
public virtual void RenameSchema(ISchemaStructure schema, string newname) { throw new NotImplementedError("DAE-00113"); }
public virtual void DropSchema(ISchemaStructure schema) { PutCmd("^drop ^schema %i", schema.SchemaName); }
public virtual void CreateSchema(ISchemaStructure schema) { PutCmd("^create ^schema %i", schema.SchemaName); }
public Schema_TreeNode(ISchemaStructure schema, IDatabaseSource conn, ITreeNode parent) : base(conn, parent, schema.SchemaName) { m_schema = schema; m_conn = conn; }
public void ChangeSchema(ISchemaStructure ssrc, ISchemaStructure sdst) { throw new NotImplementedError("DAE-00115"); }
public SchemaStructure(ISchemaStructure schema) : base(schema) { SpecificData.AddAll(schema.SpecificData); SchemaName = schema.SchemaName; }