diff --git a/Gemfile b/Gemfile index a2dcf01fe..7e4d12c8e 100644 --- a/Gemfile +++ b/Gemfile @@ -112,6 +112,8 @@ gem 'aasm' gem 'webpacker', '>= 4.0.x' +gem 'after_party' + # Cron jobs gem 'delayed_job_active_record' gem "daemons" diff --git a/Gemfile.lock b/Gemfile.lock index 2d43f9b81..326a72d48 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,6 +88,7 @@ GEM sass-rails (~> 5.0) selectize-rails (~> 0.6) aes_key_wrap (1.0.1) + after_party (1.10.0) apipie-rails (0.5.10) rails (>= 4.1) arel (9.0.0) @@ -806,6 +807,7 @@ DEPENDENCIES active_link_to active_model_serializers administrate + after_party apipie-rails bootstrap-sass (~> 3.3.5) bootstrap-wysihtml5-rails (~> 0.3.3.8) diff --git a/README.md b/README.md index 8c6d07ccc..1630cf873 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,10 @@ Pour exécuter les tests de l'application, plusieurs possibilités : bin/rake spec SPEC=file_path/file_name_spec.rb bin/rspec file_path/file_name_spec.rb +## Ajout de taches à exécuter au déploiement + + rails generate after_party:task task_name + ## Debug Une fois `overmind` lancé, et un breakpoint `byebug` inséré dans le code, il faut se connecter au process `server` dans un nouveau terminal afin d'intéragir avec byebug : diff --git a/config/deploy.rb b/config/deploy.rb index 08489b8d8..e7e6bdf23 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -110,6 +110,16 @@ namespace :yarn do end end +namespace :rails do + desc "Run deploy tasks." + task :after_party do + queue %{ + echo "-----> Running deploy tasks" + #{echo_cmd %[bin/rake after_party:run]} + } + end +end + desc "Deploys the current version to the server." task :deploy => :environment do queue 'export PATH=$PATH:/usr/local/rbenv/bin:/usr/local/rbenv/shims' @@ -122,6 +132,7 @@ task :deploy => :environment do invoke :'bundle:install' invoke :'yarn:install' invoke :'rails:db_migrate' + invoke :'rails:after_party' invoke :'rails:assets_precompile:force' to :launch do diff --git a/config/initializers/after_party.rb b/config/initializers/after_party.rb new file mode 100644 index 000000000..66c8b1071 --- /dev/null +++ b/config/initializers/after_party.rb @@ -0,0 +1,3 @@ +AfterParty.setup do |config| + require "after_party/active_record.rb" +end diff --git a/db/migrate/20180718133126_create_task_records.rb b/db/migrate/20180718133126_create_task_records.rb new file mode 100644 index 000000000..ce6d2441b --- /dev/null +++ b/db/migrate/20180718133126_create_task_records.rb @@ -0,0 +1,7 @@ +class CreateTaskRecords < ActiveRecord::Migration[5.2] + def change + create_table :task_records, id: false do |t| + t.string :version, null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index d6c557ed8..cfa20d4aa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -548,6 +548,10 @@ ActiveRecord::Schema.define(version: 2018_08_27_111451) do t.index ["administrateur_id"], name: "index_services_on_administrateur_id" end + create_table "task_records", id: false, force: :cascade do |t| + t.string "version", null: false + end + create_table "types_de_champ", id: :serial, force: :cascade do |t| t.string "libelle" t.string "type_champ"