コード例 #1
0
        public CassandraMigratorTests()
        {
            if (this.migrator is null)
            {
                var serviceProvider = this.GetTestInMemoryProvider();
                var logger          = serviceProvider.GetTestService <ILogger <CassandraMigrator> >();

                this.migrator = new CassandraMigrator(serviceProvider, logger);
                this.cfm      = serviceProvider.GetTestService <ICassandraFluentMigrator>();
            }
        }
        internal static bool ShouldApplyMigration([NotNull] this ICassandraMigrator self, [NotNull] IMigrator migration)
        {
            Check.NotNull(self, $"the argument [Cassandra Migrator]");
            Check.NotNull(migration, $"the argument [Migration]");

            var latestAppliedMigration = self.GetLatestMigration();

            if (latestAppliedMigration is null || migration.Version > new Version(latestAppliedMigration.Version))
            {
                return(true);
            }

            return(false);
        }
        internal static MigrationHistory UpdateMigrationHistory([NotNull] this ICassandraMigrator self, [NotNull] Table <MigrationHistory> table, [NotNull] IMigrator migration)
        {
            Check.NotNull(self, $"the argument [Cassandra Migrator]");
            Check.NotNull(table, $"the argument [Migration History]");
            Check.NotNull(migration, $"the argument [Migration]");

            var result = new MigrationHistory
            {
                Name        = migration.Name,
                Version     = migration.Version.ToString(),
                CreatedAt   = DateTime.UtcNow,
                Description = migration.Description,
            };

            table
            .Insert(result)
            .Execute();

            return(result);
        }
コード例 #4
0
 public CassandraMigratorController(ICassandraMigrator migrator)
 {
     this.migrator = migrator;
 }