forked from janko/budget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
42 lines (35 loc) · 1.05 KB
/
Rakefile
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
32
33
34
35
36
37
38
39
40
41
42
require "bundler/setup"
require_relative "config/settings"
require "sequel_tools"
require "sequel/core"
require "standard/rake"
db = Sequel.connect(Settings.database_url, test: false, keep_reference: false)
namespace :db do
SequelTools.inject_rake_tasks({
dbadapter: db.opts[:adapter],
dbname: db.opts[:database],
dump_schema_on_migrate: Settings.env == "development",
schema_location: "db/schema.sql",
log_level: :info,
sql_log_level: :info
}, self)
end
desc "Open a ruby console with the application loaded"
task console: :boot do
require "irb"
ARGV.clear
IRB.start
end
desc "Import new transactions into the database"
task import: :boot do
from = Date.new(2023, 1, 1)
to = Date.today
ImportTransactions.call(from: from, to: to, fio_token: Settings.fio_token_business)
ImportTransactions.call(from: from, to: to, fio_token: Settings.fio_token_shared)
end
task :backup do
system "pg_dump", db.opts[:database], out: "tmp/backup-#{Date.today.strftime("%Y%m%d")}.sql"
end
task :boot do
require_relative "config/boot"
end