Пример #1
0
        public void ChangeDomain(IDomainStructure dold, IDomainStructure dnew)
        {
            var dom = FindDomain(dold.FullName);

            if (dom == null)
            {
                throw new InternalError("DAE-00037 Domain doesn't exist: " + dold.FullName.ToString());
            }
            dom.AssignFrom(dnew);

            //Domains.RemoveIf(dom => dom.FullName == dold.FullName);
            //Domains.Add(new DomainStructure(dnew));

            // change domain references
            foreach (TableStructure tbl in Tables)
            {
                foreach (ColumnStructure col in tbl.Columns)
                {
                    if (col.Domain == dold.FullName)
                    {
                        col.Domain   = dnew.FullName;
                        col.DataType = dnew.DataType;
                    }
                }
            }
        }
Пример #2
0
 public virtual void DropDomain(IDomainStructure domain, DropFlags flags)
 {
     if (m_dialect.DialectCaps.Domains)
     {
         PutCmd("^drop ^domain %f", domain.FullName);
     }
 }
Пример #3
0
        public void RenameDomain(IDomainStructure domain, NameWithSchema newname)
        {
            DomainStructure dom = Structure.FindOrCreateDomain(domain);

            AddOperation(new AlterOperation_RenameDomain {
                OldObject = dom, NewName = newname
            });
        }
Пример #4
0
        public void CreateDomain(IDomainStructure domain)
        {
            DomainStructure dom = new DomainStructure(domain);

            AddOperation(new AlterOperation_CreateDomain {
                NewObject = dom
            });
        }
Пример #5
0
        public void DropDomain(IDomainStructure domain)
        {
            DomainStructure dom = Structure.FindOrCreateDomain(domain);

            AddOperation(new AlterOperation_DropDomain {
                OldObject = dom
            });
        }
Пример #6
0
 public override void CreateDomain(IDomainStructure domain)
 {
     PutCmd("^exec sp_addtype '%s', '%s', '%k'",
            domain.FullName.Name,
            m_dialect.GenericTypeToSpecific(domain.DataType).ToString(),
            domain.IsNullable ? "NULL" : "NOT NULL"
            );
 }
Пример #7
0
 public virtual void CreateDomain(IDomainStructure domain)
 {
     if (m_dialect.DialectCaps.Domains)
     {
         Put("^create ^domain %f ", domain.FullName);
         WriteRaw(m_dialect.GenericTypeToSpecific(domain.DataType).ToString());
         EndCommand();
     }
 }
Пример #8
0
        public void ChangeDomain(IDomainStructure domain, IDomainStructure newdomain)
        {
            DomainStructure dom    = Structure.FindOrCreateDomain(domain);
            DomainStructure newdom = new DomainStructure(newdomain);

            AddOperation(new AlterOperation_ChangeDomain {
                OldObject = dom, NewObject = newdom
            });
        }
Пример #9
0
        public void AddDomain(IDomainStructure domain, bool reuseGroupId)
        {
            var newdom = new DomainStructure(domain);

            if (!reuseGroupId)
            {
                newdom.GroupId = Guid.NewGuid().ToString();
            }
            Domains.Add(newdom);
        }
Пример #10
0
        //public IDatabaseSource TargetDb { get { return null; } }

        public DomainStructure FindOrCreateDomain(IDomainStructure domain)
        {
            DomainStructure res = FindDomain(domain.FullName);

            if (res != null)
            {
                return(res);
            }
            res = new DomainStructure(domain);
            Domains.Add(res);
            return(res);
        }
Пример #11
0
 public DomainStructure(IDomainStructure src)
     : base(src)
 {
     FullName     = src.FullName;
     DataType     = src.DataType;
     IsNullable   = src.IsNullable;
     DefaultValue = src.DefaultValue;
     CheckExpr    = src.CheckExpr;
     Collation    = src.Collation;
     CharacterSet = src.CharacterSet;
     SpecificData.AddAll(src.SpecificData);
 }
Пример #12
0
 public void DropDomain(IDomainStructure domain)
 {
     Domains.RemoveIf(dom => dom.FullName == domain.FullName);
     // remove references to domain
     foreach (TableStructure tbl in Tables)
     {
         foreach (ColumnStructure col in tbl.Columns)
         {
             if (col.Domain == domain.FullName)
             {
                 col.Domain = null;
             }
         }
     }
 }
Пример #13
0
 public static bool EqualDomains(IDomainStructure src, IDomainStructure dst, DbDiffOptions opts, bool testName)
 {
     if (testName && !DbDiffTool.EqualFullNames(src.FullName, dst.FullName, opts))
     {
         opts.DiffLogger.Trace("Domain: different names {0}; {1}", src.FullName, dst.FullName);
         return(false);
     }
     if (!EqualTypes(src.DataType, dst.DataType, opts))
     {
         opts.DiffLogger.Trace("Domain {0}, {1}: different types {2}; {3}", src.FullName, dst.FullName, src.DataType, dst.DataType);
         return(false);
     }
     if (src.IsNullable != dst.IsNullable)
     {
         opts.DiffLogger.Trace("Domain {0}, {1}: different nullable {2}; {3}", src.FullName, dst.FullName, src.IsNullable, dst.IsNullable);
         return(false);
     }
     return(true);
 }
Пример #14
0
        public void Init(IDomainStructure domain, ISqlDialect dialect)
        {
            m_oldDomain = domain;
            if (domain == null)
            {
                m_domain          = new DomainStructure();
                m_domain.DataType = new DbTypeString();
            }
            else
            {
                m_domain = new DomainStructure(domain);
            }
            m_dialect = dialect;
            cbxDataType.Items.Clear();
            foreach (string code in Enum.GetNames(m_dialect.SpecificTypeEnum).Sorted())
            {
                cbxDataType.Items.Add(code);
            }
            m_dataType = m_dialect.GenericTypeToSpecific(m_domain.DataType);
            propertyGrid1.SelectedObject = m_dataType;

            cbxDataType.SelectedIndex = cbxDataType.Items.IndexOf(((ISpecificType)m_dataType).Code.ToString());
            chbNullable.Checked       = m_domain.IsNullable;
        }
Пример #15
0
 public override void DropDomain(IDomainStructure domain)
 {
     PutCmd("^exec sp_droptype '%s'", domain.FullName.Name);
 }
Пример #16
0
        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));
            }
        }
Пример #17
0
 public DomainEditFrame(IDatabaseSource conn, IDomainStructure domain)
 {
     InitializeComponent();
     m_conn = conn;
     Init(domain, conn.Dialect);
 }
Пример #18
0
 public virtual void ChangeDomain(IDomainStructure dold, IDomainStructure dnew)
 {
     DropDomain(dold);
     CreateDomain(dnew);
 }
Пример #19
0
 public virtual void DropDomain(IDomainStructure domain)
 {
     DropDomain(domain, DropFlags.None);
 }
Пример #20
0
 public void CreateDomain(IDomainStructure domain)
 {
     AddDomain(domain, false);
 }
Пример #21
0
 public Domain_TreeNode(IDomainStructure domain, IDatabaseSource conn, ITreeNode parent)
     : base(conn, parent, domain.FullName.ToString())
 {
     m_domain = domain;
     m_conn   = conn;
 }
Пример #22
0
 public DbDefChooseDomainTreeNode(DbDefChooseDomainsTreeNode parent, IDomainStructure domain)
     : base(parent, domain.FullName.ToString())
 {
     m_db     = parent.m_db;
     m_domain = domain;
 }