Exemplo n.º 1
0
        public void can_write_schema_objects()
        {
            StoreOptions(_ => _.DatabaseSchemaName = "other");

            using (var conn = theStore.Advanced.OpenConnection())
            {
                conn.Execute(
                    cmd => cmd.Sql("drop function if exists other.mt_immutable_timestamp(text)").ExecuteNonQuery());
            }

            var function = new SystemFunction(theStore.Advanced.Options, "mt_immutable_timestamp", "text");

            var writer = new StringWriter();

            function.WriteSchemaObjects(theStore.Schema, writer);

            writer.ToString().ShouldContain("CREATE OR REPLACE FUNCTION other.mt_immutable_timestamp(value text)");
        }
Exemplo n.º 2
0
        public void can_patch_if_missing()
        {
            StoreOptions(_ => _.DatabaseSchemaName = "other");

            using (var conn = theStore.Advanced.OpenConnection())
            {
                conn.Execute(
                    cmd => cmd.Sql("drop function if exists other.mt_immutable_timestamp(text)").ExecuteNonQuery());
            }

                var function = new SystemFunction(theStore.Advanced.Options, "mt_immutable_timestamp", "text");

            var patch = new SchemaPatch(new DdlRules());

            function.WritePatch(theStore.Schema, patch);

            patch.UpdateDDL.ShouldContain("CREATE OR REPLACE FUNCTION other.mt_immutable_timestamp(value text)");
            patch.RollbackDDL.ShouldContain("drop function if exists other.mt_immutable_timestamp");
        }