Inheritance: IDbObjects
Esempio n. 1
0
        public DocumentSchema(StoreOptions options, IConnectionFactory factory, IMartenLogger logger)
        {
            _factory = factory;
            _logger  = logger;

            StoreOptions = options;

            options.AllDocumentMappings.Each(x => _mappings[x.DocumentType] = x);

            _sequences = new Lazy <SequenceFactory>(() =>
            {
                var sequences = new SequenceFactory(this, _factory, options, _logger);

                var patch = new SchemaPatch();

                sequences.GenerateSchemaObjectsIfNecessary(StoreOptions.AutoCreateSchemaObjects, this, patch);

                apply(sequences, patch);

                return(sequences);
            });

            Parser = new MartenExpressionParser(StoreOptions.Serializer(), StoreOptions);

            HandlerFactory = new QueryHandlerFactory(this, options.Serializer());

            DbObjects = new DbObjects(_factory, this);


            addSystemFunction(options, "mt_immutable_timestamp");
        }
Esempio n. 2
0
        public void DeleteAllDocuments()
        {
            var dbObjects = new DbObjects(_tenant, _options.Storage);

            using (var conn = _tenant.OpenConnection(CommandRunnerMode.Transactional))
            {
                dbObjects.DocumentTables().Each(tableName =>
                {
                    var sql = "truncate {0} cascade".ToFormat(tableName);
                    conn.Execute(sql);
                });
                conn.Commit();
            }
        }
Esempio n. 3
0
        public DocumentSchema(StoreOptions options, IConnectionFactory factory, IMartenLogger logger)
        {
            _factory = factory;
            _logger  = logger;

            StoreOptions = options;

            options.AllDocumentMappings.Each(x => _mappings[x.DocumentType] = x);

            Sequences = new SequenceFactory(this, _factory, options, _logger);

            Parser = new MartenExpressionParser(StoreOptions.Serializer(), StoreOptions);

            HandlerFactory = new QueryHandlerFactory(this, options.Serializer());

            DbObjects = new DbObjects(_factory, this);
        }
Esempio n. 4
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();
            }
        }