ActiveRecord without tuning database tables? (declarative like Django)

In Django, you fully describe your models in models.py. In Rails with ActiveRecord, you describe part of a model in the / models directory and part of it during the migration process. ActiveRecord then analyzes the model properties from existing database tables.

But I believe that migrations, columns and tables are a headache.

How can I do like Django - just declare all the properties of the model, and not inspect them from the database tables?

And for extra credit, explain where and why this would be a bad idea. :)

+3
source share
3 answers

, NoSQL. !

, , . , !

( , form activececord) tekpub

class Production

  include MongoMapper::Document

  key :title, String, :required => true
  key :slug, String, :unique => true, :required => true, :index => true
  key :description, String
  key :notes, String
  key :price, BigDecimal, :numeric => true
  key :released_at, Date, :default => Date.today
  key :default_height, String, :default => '600'
  key :default_width, String, :default => '1000'
  key :quotes, String

  #royalty info
  key :producers, String

  timestamps!
end
+2

auto_migrations. , , , .

ActiveRecord DataMapper, Rails 3. , , .

+1

, DataMapper - , . DataMapper.auto_migrate! DataMapper.auto_upgrade!. , , . . , .

, , , , , . , /. NoSQL - , Mongo, . . , , , , . MongoMapper - . tekpub .

DataMapper Merb, , 3. , rails 2.x.

+1

Source: https://habr.com/ru/post/1748605/


All Articles