-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·31 lines (25 loc) · 780 Bytes
/
Copy pathsetup
File metadata and controls
executable file
·31 lines (25 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env ruby
# frozen_string_literal: true
require_relative '../lib/ruby_at_scale'
config = RubyAtScale::Database.config
begin
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres'))
ActiveRecord::Base.connection.create_database(config['database'])
puts 'Database created.'
rescue ActiveRecord::DatabaseAlreadyExists
puts 'Database already exists.'
end
ActiveRecord::Base.establish_connection(config)
if ActiveRecord::Base.connection.table_exists?(:events)
puts 'Table already exists, skipping.'
else
ActiveRecord::Schema.define do
create_table :events do |t|
t.string :event_type
t.decimal :amount, precision: 10, scale: 2
t.timestamps
end
end
puts 'Created events table.'
end
puts 'Setup complete.'