I used to do this with sql files and had a numbering scheme but what I really wanted were ActiveRecord migrations without a full blown Rails application. Since it is just a single database I didn't need all of the typical rake tasks but I did create the following Rakefile:
The following tasks are available:
wesbailey@feynman:~/autism_data> rake -T (in /Users/wesbailey/autism_data) rake db:create # Create the database from config/database.yml for the current DATABASE_ENV rake db:drop # Drops the database for the current DATABASE_ENV rake db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false). rake db:rollback # Rolls the schema back to the previous version (specify steps w/ STEP=n). rake db:version # Retrieves the current schema version number
Instead of defining RAILS_ENV you instead define DATABASE_ENV. To specify where the migrations live you can override the default of db/migrate with MIGRATIONS_DIR. Just like with rails you define config/database.yml for database connection information.
wesbailey@feynman:~/autism_data> cat config/databases.yml development: adapter: mysql user: root password: database: autism_speaks_dev host: localhost logger: false
An example run for this database shows usage and results are just like one would expect in a full blown rails environment:
wesbailey@feynman:~/autism_data> rake db:create (in /Users/wesbailey/autism_data) wesbailey@feynman:~/autism_data> rake db:version (in /Users/wesbailey/autism_data) Current version: 0 wesbailey@feynman:~/autism_data> rake db:migrate (in /Users/wesbailey/autism_data) == CreateLoadedProviders: migrating ========================================== -- create_table(:loaded_providers) -> 0.1285s == CreateLoadedProviders: migrated (0.1288s) ================================= wesbailey@feynman:~/autism_data> rake db:version (in /Users/wesbailey/autism_data) Current version: 1 wesbailey@feynman:~/autism_data> rake db:rollback (in /Users/wesbailey/autism_data) == CreateLoadedProviders: reverting ========================================== -- drop_table(:loaded_providers) -> 0.0023s == CreateLoadedProviders: reverted (0.0024s) ================================= wesbailey@feynman:~/autism_data> rake db:drop (in /Users/wesbailey/autism_data)
Amazing post Wes! I´m starting with Rails and didn´t know Rake was so cool. To understand your code i had to research a little though. :)
ReplyDeleteThanks and keep the good work!
Thanks Bernardo! Glad you found this useful.
ReplyDeleteNice tip here. The API is easy to use, and Rake should be familiar to even a novice Rubyist, but it's nice to have quick references like this lying around. Thanks!
ReplyDeleteYou are welcome Seth! I was frustrated with the lack of info out there on how to do this. Now it is there for everyone.
ReplyDeleteI'm doing the same sort of thing with scripts and running them at the command line. Using Rake seems smart, I'm going to try that next.
ReplyDeleteHave a look at standalone migrations on github which does just that:
ReplyDeletehttps://github.com/thuss/standalone-migrations
we can always use more contributors!
Great post... Awesome!!!!
ReplyDelete@Todd I forked your project and added to it and issued a pull request. Review it if you are interested.
ReplyDeleteA post on stack overflow here:
ReplyDeletehttp://stackoverflow.com/a/9450343/365798
specifically for the use of activerecord + sinatra + JRuby + postgresql
with JRuby you need to make sure you've got the right activerecord gem adapter "activerecord-jdbcpostgresql-adapter"
Thanks. Using this right now!
ReplyDeleteDo you know why i keep getting the error:
ReplyDeleteprivate method `create_database' called for #?
Perfect, just what I needed for a small data analysis project!
ReplyDeleteThank you, I am using this. Also, thanks for your work on Autism Speaks.
ReplyDeleteThank you so much for this post. It helped me immensely setting up a no-Rails app with PostgreSQL, especially those migration rake tasks.
ReplyDeleteReally Good blog post.provided a helpful information.I hope that you will post more updates like this Ruby on Rails Online Course Bangalore
ReplyDeleteadana escort - adıyaman escort - afyon escort - aksaray escort - antalya escort - aydın escort - balıkesir escort - batman escort - bitlis escort - burdur escort - bursa escort - diyarbakır escort - edirne escort - erzurum escort - eskişehir escort - eskişehir escort - eskişehir escort - eskişehir escort - gaziantep escort - gebze escort - giresun escort - hatay escort - ısparta escort - karabük escort - kastamonu escort - kayseri escort - kilis escort - kocaeli escort - konya escort - kütahya escort - malatya escort - manisa escort - maraş escort - mardin escort - mersin escort - muğla escort - niğde escort - ordu escort - osmaniye escort - sakarya escort - samsun escort - siirt escort - sincan escort - tekirdağ escort - tokat escort - uşak escort - van escort - yalova escort - yozgat escort - urfa escort - zonguldak escort
ReplyDeleteno deposit bonus forex 2021 - takipçi satın al - takipçi satın al - takipçi satın al - tiktok takipçi satın al - instagram beğeni satın al - instagram beğeni satın al - google haritalara yer ekleme - btcturk güvenilir mi - izlenme-satin-al.com - numarasmsonay.com - borsagazete.com - takipcisatinals.com - izlenme-satin-al.com/youtube - google haritalara yer ekleme - altyapısız internet - mikrofiber havlu - forexbonus2020.com - tiktok jeton hilesi - tiktok beğeni satın al - microsoft word ücretsiz indir - misli apk indir - binance güvenilir mi - takipçi satın al - mikrofiber havlu - uc satın al - takipçi satın al - takipçi satın al - finanspedia.com
ReplyDeleteadanaescort01.com - adiyamanescortxx.com - afyonarackiralama.net - aksarayescort.net - antalyaoyunpark.com - aydinescortkiz.com - balikesirescortlar.com - batmanescortlar.com - bitlisescortlar.com - burdurescortlar.com - bursamalaysias.com - diyarbakirambar.com - edirnedespor.com - erzurumyolkosusu.com - eskisehirescortlari.com - gaziantepekspres.org - gebzeescortkiz.com - giresunmaraton.com - hataykoleji.com - ispartakpss.com - karabukteknik.com - kastamonuajans.net - kayserivalisi.com - kilisescort.com - kocaeliescortlar.com - konyaescortlar.com - kutahyaizemlak.com - malatyadataksi.com - manisaescortlar.com - marasatasoyemlak.com - mardinfanatik.com - mersinmoda.com - muglaapart.net - nigdeyapi.com - orduescortt.com - osmaniyeyorum.com - sakaryanur.com - samsunescortlar.com - siirteyatirim.com - sincanoto.com - tekirdagescortlar.com - tokatforum.com - usakbasin.com - vanescortilan.com - yalovadaemlak.com - yozgattanal.com - sanliurfadayim.com - zonguldakescort.com
ReplyDeleteinstagram takipçi satın al
ReplyDeleteinstagram takipçi satın al
takipçi satın al
instagram takipçi satın al
takipçi satın al
aşk kitapları
tiktok takipçi satın al
instagram beğeni satın al
youtube abone satın al
twitter takipçi satın al
tiktok beğeni satın al
tiktok izlenme satın al
twitter takipçi satın al
tiktok takipçi satın al
youtube abone satın al
tiktok beğeni satın al
instagram beğeni satın al
trend topic satın al
trend topic satın al
youtube abone satın al
beğeni satın al
tiktok izlenme satın al
sms onay
youtube izlenme satın al
tiktok beğeni satın al
sms onay
sms onay
perde modelleri
instagram takipçi satın al
takipçi satın al
tiktok jeton hilesi
pubg uc satın al
sultanbet
marsbahis
betboo
betboo
betboo
kayseri escort - hatay escort - kayseri escort
ReplyDeletemarsbahis
ReplyDeletebetboo
sultanbet
marsbahis
betboo
sultanbet
lab furniture manufacturer in india
ReplyDeletesteel furniture manufacturers
ReplyDeletethe connection to the server localhost:8080 was refused - did you specify the right host or port?
ReplyDeleteaws vpc
azure devops certification
azure trial account
the connection to the server localhost:8080 was refused - did you specify the right host or port?
ReplyDeleteaws vpc
aws inspector
azure traffic manager
azure-bastion
az 104 exam questions
ReplyDeletescrum certification exam questions
dp 900 exam questions
eskişehir
ReplyDeleteizmir
muğla
yalova
çanakkale
düzce
antalya
aydın
mate
bitcoin nasıl alınır
ReplyDeletetiktok jeton hilesi
youtube abone satın al
gate io güvenilir mi
referans kimliği nedir
tiktok takipçi satın al
bitcoin nasıl alınır
mobil ödeme bozdurma
mobil ödeme bozdurma