Exemplo n.º 1
0
        private void PushDummyMigrationHistoryMessage()
        {
            var migrationHistoryRow = new MigrationHistoryRow {
                Prefix = "test"
            };

            migrationHistoryRow.AppliedMigrations.Add(new MigrationHistoryRowDetails
            {
                Name           = "001_TestMigration",
                Hash           = "a0b87bef6d840b00ac344eb2a204442760794512bb8bc0873b63d8c7d5849e9f",
                DownOperations = new List <BaseOperation>
                {
                    new DeleteQueueOperation().SetName("bar"),
                    new DeleteExchangeOperation().SetName("foo")
                }
            });
            var migrationHistory = new MigrationHistory();

            migrationHistory.AllMigrations.Add(migrationHistoryRow);

            using (var connection = _connectionFactory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    var messageBody = JsonConvertHelper.SerializeObjectToByteArray(migrationHistory);
                    channel.BasicPublish("", Constants.HistoryQueue, false, null, messageBody);
                }
        }
        public void UpdateAppliedMigrations(MigrationHistoryRow appliedMigration)
        {
            Guard.ArgumentNotNull(nameof(appliedMigration), appliedMigration);

            var allAppliedMigrations = GetAllAppliedMigrations();

            if (allAppliedMigrations.AllMigrations.Any(x => x.Prefix == appliedMigration.Prefix))
            {
                var currentMigrations = allAppliedMigrations.AllMigrations.First(x => x.Prefix == appliedMigration.Prefix);

                currentMigrations.AppliedMigrations = appliedMigration.AppliedMigrations;
            }
            else
            {
                allAppliedMigrations.AllMigrations.Add(appliedMigration);
            }

            using var connection = _connectionFactory.CreateConnection();
            using var model      = connection.CreateModel();
            model.BasicGet(Constants.HistoryQueue, true);

            var messageText  = JsonConvertHelper.SerializeObjectToByteArray(allAppliedMigrations);
            var messageProps = model.CreateBasicProperties();

            messageProps.Persistent = true;
            model.BasicPublish(Constants.DefaultExchange, Constants.HistoryQueue, messageProps, messageText);
        }
Exemplo n.º 3
0
        private void PushDummyMigrationHistoryMessage()
        {
            var migrationHistoryRow = new MigrationHistoryRow {
                Prefix = "test"
            };
            var migrationHistory = new MigrationHistory {
                Version = 3
            };

            migrationHistory.AllMigrations.Add(migrationHistoryRow);

            using (var connection = _connectionFactory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    var messageBody = JsonConvertHelper.SerializeObjectToByteArray(migrationHistory);
                    channel.BasicPublish("", Constants.HistoryQueue, false, null, messageBody);
                }
        }