Saving and reading
SearchLight exposes two similar data persistence methods: save!
and save
. They both perform the same action
(persisting the object to the database), but save
will return a Bool
of value true
to indicate that the operation
was successful or a Bool
of value false
to indicate that the operation has failed. While the save!
variant will
return the persisted object upon success or will throw an exception on failure.
Migrations
Database migrations provide a way to reliably, consistently and repeatedly apply (and undo) changes to the structure of your database (known as "schema transformations"). They are specialised scripts for adding, removing and altering DB tables – these scripts are placed under version control and are managed by a dedicated system which knows which scripts have been run and which not, and is able to run them in the correct order.
Callbacks