sequent 5.0.0 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sequent +1 -1
- data/db/sequent_schema.rb +3 -3
- data/lib/sequent/configuration.rb +19 -1
- data/lib/sequent/core/aggregate_root.rb +2 -6
- data/lib/sequent/core/aggregate_roots.rb +2 -6
- data/lib/sequent/core/command.rb +8 -12
- data/lib/sequent/core/command_service.rb +13 -2
- data/lib/sequent/core/core.rb +1 -0
- data/lib/sequent/core/event.rb +2 -2
- data/lib/sequent/core/event_store.rb +15 -2
- data/lib/sequent/core/ext/ext.rb +17 -0
- data/lib/sequent/core/helpers/attribute_support.rb +1 -0
- data/lib/sequent/core/helpers/default_validators.rb +3 -0
- data/lib/sequent/core/helpers/param_support.rb +2 -0
- data/lib/sequent/core/helpers/string_to_value_parsers.rb +5 -0
- data/lib/sequent/core/helpers/time_validator.rb +23 -0
- data/lib/sequent/core/helpers/value_validators.rb +11 -0
- data/lib/sequent/core/middleware/chain.rb +37 -0
- data/lib/sequent/core/middleware/middleware.rb +3 -0
- data/lib/sequent/core/projector.rb +3 -11
- data/lib/sequent/core/workflow.rb +3 -11
- data/lib/sequent/generator/template_project/Rakefile +2 -2
- data/lib/sequent/generator/template_project/db/sequent_schema.rb +3 -3
- data/lib/sequent/generator/template_project/spec/spec_helper.rb +1 -1
- data/lib/sequent/migrations/migrations.rb +1 -0
- data/lib/sequent/migrations/projectors.rb +2 -2
- data/lib/sequent/migrations/sequent_schema.rb +40 -0
- data/lib/sequent/migrations/view_schema.rb +39 -3
- data/lib/sequent/rake/migration_tasks.rb +36 -33
- data/lib/sequent/support/database.rb +29 -13
- data/lib/sequent/test/command_handler_helpers.rb +1 -1
- data/lib/sequent/test/database_helpers.rb +20 -0
- data/lib/sequent/test/time_comparison.rb +2 -5
- data/lib/sequent/test/{event_handler_helpers.rb → workflow_helpers.rb} +24 -10
- data/lib/sequent/test.rb +2 -1
- data/lib/sequent/util/dry_run.rb +1 -1
- data/lib/version.rb +1 -1
- metadata +22 -12
- data/lib/sequent/rake/tasks.rb +0 -121
data/lib/sequent/rake/tasks.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_record'
|
4
|
-
require 'rake'
|
5
|
-
require 'rake/tasklib'
|
6
|
-
|
7
|
-
require 'sequent/support'
|
8
|
-
|
9
|
-
module Sequent
|
10
|
-
module Rake
|
11
|
-
class Tasks < ::Rake::TaskLib
|
12
|
-
include ::Rake::DSL
|
13
|
-
|
14
|
-
DEFAULT_OPTIONS = {
|
15
|
-
migrations_path: 'db/migrate',
|
16
|
-
event_store_schema: 'public',
|
17
|
-
}.freeze
|
18
|
-
|
19
|
-
attr_reader :options
|
20
|
-
|
21
|
-
def initialize(options)
|
22
|
-
super()
|
23
|
-
@options = DEFAULT_OPTIONS.merge(options)
|
24
|
-
end
|
25
|
-
|
26
|
-
def display_deprecation_warning
|
27
|
-
warn '[DEPRECATED] Sequent::Rake::Tasks is deprecated. Please use Sequent::Rake::MigrationTasks tasks instead.'
|
28
|
-
end
|
29
|
-
|
30
|
-
def register!
|
31
|
-
display_deprecation_warning
|
32
|
-
|
33
|
-
register_db_tasks!
|
34
|
-
register_view_schema_tasks!
|
35
|
-
end
|
36
|
-
|
37
|
-
def register_db_tasks!
|
38
|
-
namespace :db do
|
39
|
-
desc 'Create the database'
|
40
|
-
task :create do
|
41
|
-
display_deprecation_warning
|
42
|
-
|
43
|
-
current_environments.each do |env|
|
44
|
-
env_db = db_config(env)
|
45
|
-
puts "Create database #{env_db['database']}"
|
46
|
-
Sequent::Support::Database.create!(env_db)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
desc 'Drop the database'
|
51
|
-
task :drop do
|
52
|
-
display_deprecation_warning
|
53
|
-
|
54
|
-
current_environments.each do |env|
|
55
|
-
env_db = db_config(env)
|
56
|
-
puts "Drop database #{env_db['database']}"
|
57
|
-
Sequent::Support::Database.drop!(env_db)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
task :establish_connection do
|
62
|
-
env_db = db_config(options.fetch(:environment))
|
63
|
-
ActiveRecord::Base.establish_connection(env_db)
|
64
|
-
end
|
65
|
-
|
66
|
-
desc 'Migrate the database'
|
67
|
-
task migrate: :establish_connection do
|
68
|
-
display_deprecation_warning
|
69
|
-
|
70
|
-
database.create_schema!(options.fetch(:event_store_schema))
|
71
|
-
database.migrate(options.fetch(:migrations_path))
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def register_view_schema_tasks!
|
77
|
-
namespace :view_schema do
|
78
|
-
desc 'Build the view schema'
|
79
|
-
task build: :'db:establish_connection' do
|
80
|
-
display_deprecation_warning
|
81
|
-
|
82
|
-
if database.schema_exists?(view_projection.schema_name)
|
83
|
-
puts "View version #{view_projection.version} already exists; no need to build it"
|
84
|
-
else
|
85
|
-
database.create_schema!(view_projection.schema_name)
|
86
|
-
view_projection.build!
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
desc 'Drop the view schema'
|
91
|
-
task drop: :'db:establish_connection' do
|
92
|
-
display_deprecation_warning
|
93
|
-
|
94
|
-
database.drop_schema!(view_projection.schema_name)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
private
|
100
|
-
|
101
|
-
def current_environments
|
102
|
-
environment = options.fetch(:environment)
|
103
|
-
envs = [environment]
|
104
|
-
envs << 'test' if environment == 'development'
|
105
|
-
envs
|
106
|
-
end
|
107
|
-
|
108
|
-
def database
|
109
|
-
@database ||= Sequent::Support::Database.new
|
110
|
-
end
|
111
|
-
|
112
|
-
def db_config(environment)
|
113
|
-
options.fetch(:db_config_supplier)[environment] or fail "No database config for #{environment}"
|
114
|
-
end
|
115
|
-
|
116
|
-
def view_projection
|
117
|
-
options.fetch(:view_projection)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|