ruby on rails - How should i handle migrations with 2 apps and 1 database -
in our project have 2 distinct apps (3 if think resque workers), use different users same database in remote db server.
the idea 1 app writes stuff on db
, other reads stuff db
. both have same models same attributes, security reasons 1 app cannot in circumstance write on db.
because of setup have questions:
- how can ensure both apps in development have same migrations? should run migrations on 1 , copy code?
- if change on 1 model, best way sync changes?
- how should handle capistrano migrating database? should ignore it? or should create logic stop servers behind migration?
edit
i've done research , found solutions still don't feel confident using.
- creating gem hold model data
- too messy handle
- for 1 small change need many things update gem
- use
git submodule
orgit subtree
- not straightforward
- nice handle shared models i've no idea migrations
edit 2
i have config each app:
# worker , admin, need write production: adapter: mysql2 encoding: utf8 reconnect: false database: my_huge_db_production pool: 5 username: full_access_user password: password socket: /tmp/mysql.sock # api, need read production: adapter: mysql2 encoding: utf8 reconnect: false database: my_huge_db_production pool: 5 username: only_read_access_user password: password socket: /tmp/mysql.sock
my biggest problem how sync changes on models , migrations when deploy can say: call migrations on admin app
the sinatra app expose api, shouldn't telling business rules of models , tables.
the resque app handle heavy i/o, long requests , stuffs. shouldnt telling nothinng well.
the rails app important app, because should handle business logic, user interface (html/css/javascript). tell how api should be, since api based on models defined on it. think thats 1 handle migrations.
if go deeper, see rails app center point of system. =)
Comments
Post a Comment