Example #1
0
        public void Initialize()
        {
            try
            {
                Catfish.Tests.Migrations.Configuration config = new Catfish.Tests.Migrations.Configuration();
                var migrator = new DbMigrator(config);

                foreach (string migName in migrator.GetPendingMigrations())
                {
                    Type        migration = config.MigrationsAssembly.GetType(string.Format("{0}.{1}", config.MigrationsNamespace, migName.Substring(16)));
                    DbMigration m         = (DbMigration)Activator.CreateInstance(migration);
                    m.Up();

                    var prop = m.GetType().GetProperty("Operations", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                    if (prop != null)
                    {
                        IEnumerable <MigrationOperation> operations = prop.GetValue(m) as IEnumerable <MigrationOperation>;
                        var generator  = config.GetSqlGenerator("System.Data.SQLite");
                        var statements = generator.Generate(operations, "2008");
                        foreach (MigrationStatement item in statements)
                        {
                            Db.Database.ExecuteSqlCommand(item.Sql);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        public void Initialize(MockConnection solrConnection)
        {
            //if (SolrService.IsInitialized)
            //{
            //    //TODO: Inject the new connection into this current solr thread.
            //}
            //else
            //{
            //    SolrService.ForceInit(solrConnection);
            //}

            SolrService.ForceInit(solrConnection);

            try
            {
                Catfish.Tests.Migrations.Configuration config = new Catfish.Tests.Migrations.Configuration();
                var migrator = new DbMigrator(config);

                foreach (string migName in migrator.GetLocalMigrations())
                {
                    Type        migration = config.MigrationsAssembly.GetType(string.Format("{0}.{1}", config.MigrationsNamespace, migName.Substring(16)));
                    DbMigration m         = (DbMigration)Activator.CreateInstance(migration);
                    m.Up();

                    var prop = m.GetType().GetProperty("Operations", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                    if (prop != null)
                    {
                        IEnumerable <MigrationOperation> operations = prop.GetValue(m) as IEnumerable <MigrationOperation>;
                        var generator  = config.GetSqlGenerator("System.Data.SQLite");
                        var statements = generator.Generate(operations, "2008");
                        foreach (MigrationStatement item in statements)
                        {
                            Db.Database.ExecuteSqlCommand(item.Sql);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }