Added support for ActiveRecord 8.0
Updated to call ActiveRecord::Base.connection_handler.clear_active_connections!
on Rails 7 and above, as calling ActiveRecord::Base.connection_handler.clear_active_connections!
is deprecated. Thanks Mr Rogres (@bunnymatic) for contributing to this
Removed unused variables, and removed support for ruby 2.5
- Added support for ActiveRecord 7.0
- Fixed compatibility with Psych version 4.0.0+ , use unsafe_load if available.
- Added Ruby 3.0 and head (latest version of Ruby) to the CI matrix Thanks Onaka (@onk) for contributing to this.
- For ActiveRecord 6.0 and above, if the the configuration (database.yml) has multiple databases defined, it will discard the DATABASE_URL spec (if it is supplied from environment variables), following Active Record convention here. Thanks JoakimKlaxit (@JoakimKlaxit) for contributing to this.
- Added compability fix for ActiveRecord 6.1 (#107), as they have moved ConnectionUrlResolver to another module. Thanks Richard Peck(@richpeck) for contributing to this.
- If both config/database.yml and $DATABASE_URL is present, the database configuration will be merged from this two, and $DATABASE_URL's variables will take precedence. (sinatra-activerecord#103)
- Don't try to load config/database.yml if
$DATABASE_URL
is present (#55, thanks to @exviva)
- Use the ConnectionManagement AR middelware for clearing active connections
- Allow multiple databases to be used (#54)
- Prefer
DATABASE_URL
to config/database.yml (#47).
- Disabled ActiveRecord logging in tests
-
You're now encouraged to load the app in the
:load_config
Rake task. This way your app will only be required when executing ActiveRecord tasks, and not other potential tasks which don't need the database. Your Rakefile can now be updated to this:require "sinatra/activerecord/rake" namespace :db do task :load_config do require "./app" # or whatever your app name is end end
-
ActiveRecord isn't logged in production anymore.
- Use
File.exist?
instead ofFile.exists?
to avoid warnings (thanks to @matthiase).
- Allow setting the environment as a String, aside from Symbol.
- Fixed the issue where it mattered in which order
sinatra/activerecord/rake
and./app
are required.
- ActiveRecord 4.1 is now supported.
- Rake tasks are now directly imported from ActiveRecord, which means all of the tasks are now available.
- Added
db:reset
anddb:migrate:reset
tasks (#27). Thanks to @csgavino.
- Added ability to specify folder for the database (#26). Thanks to @jamesrwhite.
- Added ability to specify
:sql
format of the schema, as well asdb:structure
tasks (#25). Thanks to @icambron.
- Added
db:test:prepare
Rake task.
- Added
db:create
,db:drop
anddb:reset
Rake tasks.
- Fix a bug with ActiveRecord 3.0.
- By default look for a
config/database.yml
in the root of the running process.
- Allow ActiveRecord 4
- Fix not allowing environments other than "development", "test" and "production".
- Fix specifying database from a file not working properly.
-
You can now set a custom migrations directory. Take a look at this wiki.
-
You can now set the database to a YAML file. Take a look at this wiki.
- Users are now warned if they use SQLite URLs with 2 slashes.
- The
set :database
command now accepts everything thatActiveRecord::Base.establish_connection
accepts. A Hash is one example:
set :database, {
adapter: "sqlite3",
database: "db/foo.db",
pool: 5,
timeout: 5000
}
- The database is now reset whenever you specify it with
set :database
. - The migrations are now logged just like in Rails.
- If no database is specified, it will try to read from the
DATABASE_URL
environment variable (which is often set in production). This was removed in 1.0.0, but now I'm bringing it back.
- Removed deprecation warnings when using the
#database
helper.
- Fixed the database not working. Sorry, I won't let it happen again.
-
There is no more "default" database. Now you always have to specify the database you want to connect to, it doesn't default to
"sqlite://#{environment}.db"
anymore. -
When you're setting an SQLite database, you now have to put 3 slashes after
sqlite:
instead of 2. So instead ofsqlite://database.db
you have to writesqlite:///database.db
. This is now a valid URL.
- The previous version was yanked, because I forgot to add the
db:rollback
task (I didn't figure out how to test it yet, otherwise I would know it was missing). This version is then actually 0.2.0.
-
Added
db:rollback
rake task. -
If you're using SQLite, you can now specify the path to where you want your database file to be (thanks to @mpalmer for this). Refer to this wiki.
-
Verify connection before requests (a MySQL error which caused the app to disconnect from the database after some longer time).
-
Clear active connections after each request.
-
activerecord
gem is now a dependency, so you don't have to specify it anymore. The required version is >= 3.