public static string ScriptForCreateColumn(MigrationColumn column)
        {
            var script = Script.New();

            script.AppendLine("Create.Column(\"{0}\").OnTable(\"{1}\"){2}", column.Name, column.OwnerTable.Name, column.ScriptActions());
            script.AppendSemicolon();

            
            // if foreign key
            var foreignkeyColumn = column as ForeignKeyColumn;
            if (foreignkeyColumn != null)
            {
                script.AppendEmptyLine();
                script.Append(ScriptForCreateForeignKey(foreignkeyColumn));
            }


            return script.ToString();
        }
        public static string ScriptForCreateColumn(MigrationColumn column)
        {
            var script = Script.New();

            script.AppendLine("Create.Column(\"{0}\").OnTable(\"{1}\"){2}", column.Name, column.OwnerTable.Name, column.ScriptActions());
            script.AppendSemicolon();


            // if foreign key
            var foreignkeyColumn = column as ForeignKeyColumn;

            if (foreignkeyColumn != null)
            {
                script.AppendEmptyLine();
                script.Append(ScriptForCreateForeignKey(foreignkeyColumn));
            }


            return(script.ToString());
        }
        public static string ScriptForAlterColumn(MigrationColumn oldColumn, MigrationColumn newColumn)
        {
            var script = Script.New();

            var oldforeignkeyColumn = oldColumn as ForeignKeyColumn;
            var newforeignkeyColumn = newColumn as ForeignKeyColumn;
            if ((oldforeignkeyColumn != null && newforeignkeyColumn == null) // the column is no more a foreign key
               || (oldforeignkeyColumn != null && newforeignkeyColumn != null && oldforeignkeyColumn.ReferencedTableName != newforeignkeyColumn.ReferencedTableName))  // the foreign key has changed target
            
            {
                script.Append(ScriptForDeleteForeignKey(oldforeignkeyColumn));
                script.AppendEmptyLine();
            }

            script.AppendLine("// WARNING ! this column alteration might not work properly without specific data migration code");
            script.AppendLine("Alter.Column(\"{0}\").OnTable(\"{1}\"){2}", newColumn.Name, newColumn.OwnerTable.Name, newColumn.ScriptActions());
            script.AppendSemicolon();

            if ((oldforeignkeyColumn == null && newforeignkeyColumn != null) // the column has become a foreign key
                || (oldforeignkeyColumn != null && newforeignkeyColumn != null && oldforeignkeyColumn.ReferencedTableName != newforeignkeyColumn.ReferencedTableName))  // the foreign key has changed target
            
            {
                script.AppendEmptyLine();
                script.Append(ScriptForCreateForeignKey(newforeignkeyColumn));
                script.AppendEmptyLine();
            }

            return script.ToString();
        }
        public static string ScriptForAlterColumn(MigrationColumn oldColumn, MigrationColumn newColumn)
        {
            var script = Script.New();

            var oldforeignkeyColumn = oldColumn as ForeignKeyColumn;
            var newforeignkeyColumn = newColumn as ForeignKeyColumn;

            if ((oldforeignkeyColumn != null && newforeignkeyColumn == null) || // the column is no more a foreign key
                (oldforeignkeyColumn != null && newforeignkeyColumn != null && oldforeignkeyColumn.ReferencedTableName != newforeignkeyColumn.ReferencedTableName))    // the foreign key has changed target

            {
                script.Append(ScriptForDeleteForeignKey(oldforeignkeyColumn));
                script.AppendEmptyLine();
            }

            script.AppendLine("// WARNING ! this column alteration might not work properly without specific data migration code");
            script.AppendLine("Alter.Column(\"{0}\").OnTable(\"{1}\"){2}", newColumn.Name, newColumn.OwnerTable.Name, newColumn.ScriptActions());
            script.AppendSemicolon();

            if ((oldforeignkeyColumn == null && newforeignkeyColumn != null) || // the column has become a foreign key
                (oldforeignkeyColumn != null && newforeignkeyColumn != null && oldforeignkeyColumn.ReferencedTableName != newforeignkeyColumn.ReferencedTableName))     // the foreign key has changed target

            {
                script.AppendEmptyLine();
                script.Append(ScriptForCreateForeignKey(newforeignkeyColumn));
                script.AppendEmptyLine();
            }

            return(script.ToString());
        }