Sha256: 8ad39114b9127338d65d360c486603261367bd7076a67102bebb53899e070312

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

def check_environment!
  if !Rails.env.development?
    raise "Database commands are only supported in development environment"
  end

  ENV['SKIP_TEST_DATABASE'] = "1"
  ENV['SKIP_MULTISITE'] = "1"
end

desc 'Run db:migrate:reset task and populate sample content for development environment'
task 'dev:reset' => ['db:load_config'] do |_, args|
  check_environment!

  Rake::Task['db:migrate:reset'].invoke
  Rake::Task['dev:config'].invoke
  Rake::Task['dev:populate'].invoke
end

desc 'Initialize development environment'
task 'dev:config' => ['db:load_config'] do |_, args|
  DiscourseDev.config.update!
end

desc 'Populate sample content for development environment'
task 'dev:populate' => ['db:load_config'] do |_, args|
  Rake::Task['groups:populate'].invoke
  Rake::Task['users:populate'].invoke
  Rake::Task['categories:populate'].invoke
  Rake::Task['tags:populate'].invoke
  Rake::Task['topics:populate'].invoke
  system("redis-cli flushall")
end

desc 'Repopulate sample datas in development environment'
task 'dev:repopulate' => ['db:load_config'] do |_, args|
  require 'highline/import'

  answer = ask("Do you want to repopulate the database with fresh data? It will recreate DBs and run migration from scratch before generating all the samples. (Y/n)  ")

  if (answer == "" || answer.downcase == 'y')
    Rake::Task['dev:reset'].invoke
  else
    puts "You can run `dev:reset` rake task to do this repopulate action anytime."
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse_dev-0.1.0 lib/discourse_dev/tasks/dev.rake
discourse_dev-0.0.9 lib/discourse_dev/tasks/dev.rake
discourse_dev-0.0.8 lib/discourse_dev/tasks/dev.rake