Sha256: 87025cca79cb7da2d406b710c60cdcb83d445fce5bebc525ea2d6aaca0a69030

Contents?: true

Size: 1008 Bytes

Versions: 9

Compression:

Stored size: 1008 Bytes

Contents

namespace :optimacms do
namespace :install do

  desc "Set admin password or create a new admin user"
  task :set_admin_user, [:email, :password] => :environment do |t, args|
    email = args[:email]
    row = Optimacms::CmsAdminUser.where(email: email).first || Optimacms::CmsAdminUser.new(email: email)
    row.password = args[:password]
    row.password_confirmation = args[:password]

    row.save
  end


  desc 'import db'
  task :import_db => :environment do
    #ActiveRecord::Base.connection.execute(IO.read("db-init/gex.sql"))

    # init.sql
    filename = ENV['filename'] || '__db/init.sql'
    script = Rails.root.join(filename).read

    # this needs to match the delimiter of your queries
    statements = script.split /;$/

    ActiveRecord::Base.transaction do
      statements.each do |stmt|
        s = stmt.strip
        #puts "s='#{s}'"

        next if stmt.blank?
        ActiveRecord::Base.connection.execute(stmt)
      end
    end
  end
end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
optimacms-0.3.35 tasks/optimacms/install.rake
optimacms-0.3.34 tasks/optimacms/install.rake
optimacms-0.3.30 tasks/optimacms/install.rake
optimacms-0.3.29 tasks/optimacms/install.rake
optimacms-0.3.23 tasks/optimacms/install.rake
optimacms-0.3.15 lib/tasks/optimacms/install.rake
optimacms-0.3.12 lib/tasks/optimacms/install.rake
optimacms-0.3.11 lib/tasks/optimacms/install.rake
optimacms-0.3.4 lib/tasks/optimacms/install.rake