public void write_ddl_by_type_generates_the_all_sql_script()
        {
            using (var store = DocumentStore.For(_ =>
            {
                _.RegisterDocumentType<User>();
                _.RegisterDocumentType<Company>();
                _.RegisterDocumentType<Issue>();

                _.Events.AddEventType(typeof(MembersJoined));

                _.Connection(ConnectionSource.ConnectionString);

                _.Transforms.LoadFile("get_fullname.js");
            }))
            {
                store.Schema.WriteDDLByType(@"bin\allsql");
            }

            var filename = @"bin\allsql".AppendPath("all.sql");

            var lines = new FileSystem().ReadStringFromFile(filename).ReadLines().ToArray();

            lines.ShouldContain("\\i user.sql");
            lines.ShouldContain("\\i company.sql");
            lines.ShouldContain("\\i issue.sql");
            lines.ShouldContain("\\i mt_hilo.sql");
            lines.ShouldContain("\\i eventstore.sql");
            lines.ShouldContain("\\i get_fullname.sql");


        }
        public void writes_transform_function()
        {
            using (var store = DocumentStore.For(_ =>
            {
                _.RegisterDocumentType<User>();
                _.RegisterDocumentType<Company>();
                _.RegisterDocumentType<Issue>();

                _.Events.AddEventType(typeof(MembersJoined));

                _.Connection(ConnectionSource.ConnectionString);

                _.Transforms.LoadFile("get_fullname.js");
            }))
            {
                store.Schema.WriteDDLByType(@"bin\allsql");
            }

            var file = @"bin\allsql".AppendPath("get_fullname.sql");
            var lines = new FileSystem().ReadStringFromFile(file).ReadLines().ToArray();


            lines.ShouldContain("CREATE OR REPLACE FUNCTION public.mt_transform_get_fullname(doc JSONB) RETURNS JSONB AS $$");
        }
        public void write_ddl_by_type_generates_the_all_sql_script()
        {
            using (var store = DocumentStore.For(_ =>
            {
                _.RegisterDocumentType<User>();
                _.RegisterDocumentType<Company>();
                _.RegisterDocumentType<Issue>();

                _.DatabaseSchemaName = "yet_another";
                _.Schema.For<User>().DatabaseSchemaName("other");

                _.Events.AddEventType(typeof(MembersJoined));

                _.Connection(ConnectionSource.ConnectionString);
            }))
            {
                store.Schema.WriteDDLByType(@"bin\allsql");
            }

            var filename = @"bin\allsql".AppendPath("all.sql");

            var lines = new FileSystem().ReadStringFromFile(filename).ReadLines().Select(x => x.Trim()).ToArray();

            // should create the schemas too
            lines.ShouldContain("EXECUTE 'CREATE SCHEMA yet_another';");
            lines.ShouldContain("EXECUTE 'CREATE SCHEMA other';");

            lines.ShouldContain("\\i user.sql");
            lines.ShouldContain("\\i company.sql");
            lines.ShouldContain("\\i issue.sql");
            lines.ShouldContain("\\i mt_hilo.sql");
            lines.ShouldContain("\\i eventstore.sql");
        }