Beispiel #1
0
 internal override string Create(InterItemCommunication communication)
 {
     return(base.Create(communication) + "()");
 }
Beispiel #2
0
 internal override string Alter(ItemComparable target, InterItemCommunication communication)
 {
     return(Create(communication));
 }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Communication = new InterItemCommunication();

            var fileName = DateTime.Now.ToString("yyyyMMddHHmmss");

            string sql = CompareSchema(DBHelper.GetSourceDatabase(), DBHelper.GetTargetDatabase());

            string tempPath = $@"D:\sql\temp\updateschema{fileName}.sql";

            SaveTxtFile(tempPath, sql);


            List <string> sqlLines = File.ReadAllLines(tempPath).Where(o => string.IsNullOrWhiteSpace(o) == false).ToList();


            Table        table      = new Table();
            List <Table> sourceList = ReturnItemList <Table>(DBHelper.GetSourceDatabase(), table.Query);

            List <string> orderSqls = new List <string>();

            var i = 0;

            foreach (var sourceTable in sourceList)
            {
                i++;
                var sqls = sqlLines.Where(o => o.Contains(sourceTable.Name)).ToList();
                if (sqls.Any())
                {
                    orderSqls.AddRange(sqls);
                    orderSqls.Add(i.ToString());
                }
            }

            orderSqls = orderSqls.Distinct().ToList();

            string path = $@"D:\sql\updateschema{fileName}.sql";

            foreach (var orderSql in orderSqls)
            {
                if (int.TryParse(orderSql, out i))
                {
                    SaveTxtFile(path, "");
                }
                else
                {
                    SaveTxtFile(path, orderSql);
                }
            }



            if (string.IsNullOrWhiteSpace(sql))
            {
                MessageBox.Show("没有要修改的sql脚本");
            }
            else
            {
                MessageBox.Show($"脚本路径{path}");
            }
        }
Beispiel #4
0
 internal override string Drop(InterItemCommunication communication)
 {
     return($"COMMENT ON {ElementType} {Name} IS ''");
 }
Beispiel #5
0
 internal override string Create(InterItemCommunication communication)
 {
     return(Definition);
 }
Beispiel #6
0
 internal override string Drop(InterItemCommunication communication)
 {
     return($"DROP TRIGGER {Name} ON {TableName}");
 }
Beispiel #7
0
 internal override string Create(InterItemCommunication communication)
 {
     return($"COMMENT ON {ElementType} {Name} IS '{Definition.Replace("'","''")}'");
 }
Beispiel #8
0
 internal override string Create(InterItemCommunication communication)
 {
     return($"CREATE SCHEMA {Name} AUTHORIZATION {this.Owner};");
 }
Beispiel #9
0
 internal override string Alter(ItemComparable target, InterItemCommunication communication)
 {
     return(string.Empty);
 }
Beispiel #10
0
 internal override string Drop(InterItemCommunication communication)
 {
     return("");
 }
Beispiel #11
0
 internal override string Create(InterItemCommunication communication)
 {
     return($@"{Alter(null, communication)}");
 }
Beispiel #12
0
 internal override string Alter(ItemComparable target, InterItemCommunication communication)
 {
     return($"ALTER {ElementType} {TableName} OWNER TO {Name}");
 }
Beispiel #13
0
 internal override string Drop(InterItemCommunication communication)
 {
     return(string.Empty);//TODO:这里不需要生成删除序列的
 }
Beispiel #14
0
 internal override string Create(InterItemCommunication communication)
 {
     return($"CREATE {ElementType} IF NOT EXISTS {Name} INCREMENT {this["increment_by"]} MINVALUE {this["min_value"]} MAXVALUE {this["max_value"]} START {this["start_value"]};");
 }