Sha256: bf11dd1a174c8f8e8703594084457fa3012a2253b44cd3bbf73929b07c172952
Contents?: true
Size: 1.97 KB
Versions: 4
Compression:
Stored size: 1.97 KB
Contents
namespace :db do namespace :migrate do desc "Preview table updates" task :preview => :environment do if File.exists?('db/models.yml') EZ::DomainModeler.update_tables(false, true) else puts "Nothing to preview." end end end end namespace :ez do desc "Generate models.yml if it doesn't exist yet." task :generate_yml do filename = "db/models.yml" unless File.exist?(filename) File.open(filename, "w") do |f| f.puts <<-EOS # Example table for a typical Book model. # # Book # title: string # author_id: integer # price: integer # summary: text # hardcover: boolean # # Indent consistently! Follow the above syntax exactly. # Typical column choices are: string, text, integer, boolean, date, time, and datetime. # # # About Default Values # ---------------------------------------------------- # Default column values can be specified like this: # price: integer(0) # # If not specified, Boolean columns always default to false. # # # Convention-Based Defaults: # ---------------------------------------------------- # You can omit the column type if it's a string, or if it's obviously an integer column: # # # Book # title # author_id # price: integer # summary: text # hardcover: boolean # # Complete details are in the README file online. # # Have fun! EOS end end end desc "Erases all data, and builds all table schema from scratch." task :reset_tables => ['db:drop', :tables] do end desc "Attempts to update the database schema and model files with minimal data loss." task :tables => [:environment] do if File.exists?('db/models.yml') if EZ::DomainModeler.update_tables Rake::Task["db:schema:dump"].invoke if (Rails.env.development? || Rails.env.test?) end else Rake::Task["ez:generate_yml"].invoke emit_help_page end end def emit_help_page puts "You can now edit the db/models.yml file to describe your table schema." end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ez-1.5.0.5 | lib/tasks/ez_tasks.rake |
ez-1.5.0.4 | lib/tasks/ez_tasks.rake |
ez-1.5.0.3 | lib/tasks/ez_tasks.rake |
ez-1.5.0.2 | lib/tasks/ez_tasks.rake |