Exemplo n.º 1
0
        public void CompletelyRemoveAll()
        {
            var dbObjects = new DbObjects(_tenant, _options.Storage);

            using (var connection = _tenant.OpenConnection(CommandRunnerMode.Transactional))
            {
                var schemaTables = dbObjects.SchemaTables();
                schemaTables
                .Each(tableName => { connection.Execute($"DROP TABLE IF EXISTS {tableName} CASCADE;"); });

                var drops = connection.GetStringList(DropAllFunctionSql, new object[] { _options.Storage.AllSchemaNames() });
                drops.Each(drop => connection.Execute(drop));
                connection.Commit();

                _tenant.ResetSchemaExistenceChecks();
            }
        }
Exemplo n.º 2
0
        public async Task CompletelyRemoveAllAsync()
        {
            using var conn = _tenant.CreateConnection();
            await conn.OpenAsync();

            var schemas = _options.Storage.AllSchemaNames();
            var tables  = await conn.ExistingTables("mt_%", schemas);

            var builder = new CommandBuilder();


            foreach (var table in tables)
            {
                builder.Append($"DROP TABLE IF EXISTS {table} CASCADE;");
            }

            var functionDrops = await conn.CreateCommand(DropAllFunctionSql)
                                .With("schemas", schemas)
                                .FetchList <string>();

            foreach (var functionDrop in functionDrops)
            {
                builder.Append(functionDrop);
            }

            var sequenceDrops = await conn.CreateCommand(DropAllSequencesSql)
                                .With("schemas", schemas)
                                .FetchList <string>();

            foreach (var sequenceDrop in sequenceDrops)
            {
                builder.Append(sequenceDrop);
            }

            if (tables.Any() || functionDrops.Any() || sequenceDrops.Any())
            {
                await builder.ExecuteNonQueryAsync(conn);
            }

            _tenant.ResetSchemaExistenceChecks();
        }
Exemplo n.º 3
0
 public void ResetSchemaExistenceChecks()
 {
     _inner.ResetSchemaExistenceChecks();
 }