@@ -17,70 +17,4 @@ namespace :db do
1717
1818 puts "tmp/#{ dump_to } "
1919 end
20-
21- desc 'Dumps staff applications to be reloaded later'
22- task dump_staff_applications : :environment do
23- FileUtils . rm_rf ( 'tmp/staff_applications.yml' )
24-
25- applications = [ ]
26- staff_applications = [ ]
27- tokens = [ ]
28-
29- StaffApplication . all . includes ( :application ) . map do |app |
30- applications . push ( app . application . attributes )
31- staff_applications . push ( app . attributes )
32- tokens . push ( *app . application . access_tokens . map ( &:attributes ) )
33- end
34-
35- File . write (
36- 'tmp/staff_applications.yml' ,
37- {
38- 'applications' => applications ,
39- 'staff_applications' => staff_applications ,
40- 'tokens' => tokens
41- } . to_yaml
42- )
43-
44- FileUtils . chmod ( 0o600 , 'tmp/staff_applications.yml' )
45- rescue StandardError
46- FileUtils . rm ( 'tmp/staff_applications.yml' ) if File . exist? ( 'tmp/staff_applications.yml' )
47- end
48-
49- desc 'Loads staff applications from a dump'
50- task load_staff_applications : :environment do
51- unless File . exist? ( 'tmp/staff_applications.yml' )
52- puts 'No staff applications dump found'
53- exit
54- end
55-
56- apps = YAML . unsafe_load_file ( 'tmp/staff_applications.yml' )
57-
58- StaffApplication . transaction do
59- StaffApplication . destroy_all
60-
61- OAuthApplication . insert_all! ( apps [ 'applications' ] ) if apps [ 'applications' ] . any?
62- StaffApplication . insert_all! ( apps [ 'staff_applications' ] ) if apps [ 'staff_applications' ] . any?
63- Doorkeeper ::AccessToken . insert_all! ( apps [ 'tokens' ] ) if apps [ 'tokens' ] . any?
64-
65- FileUtils . rm ( 'tmp/staff_applications.yml' )
66- rescue StandardError
67- puts <<~MESSAGE
68- ┌─────────────────────────────────────────────────────────────────────────┐
69- │ !!!️ CONNECTING ETMODEL AND TRANSITION PATHS !!!️ │
70- ├─────────────────────────────────────────────────────────────────────────┤
71- │ Importing a database dump removed the credentials used to connect your │
72- │ local ETModel or Transition Paths app with ETEngine. │
73- │ │
74- │ If you wish you connect ETModel or Transition Paths with your local │
75- │ ETEngine: │
76- │ │
77- │ 1. Start ETEngine: bundle exec rails server. │
78- │ 2. Sign in to your account at http://localhost:3000. │
79- │ 3. Scroll down and create a new ETModel or Transition Path application. │
80- │ 4. Copy the generated config to the other application. │
81- │ 5. Restart the other application. │
82- └─────────────────────────────────────────────────────────────────────────┘
83- MESSAGE
84- end
85- end
8620end
0 commit comments