Permalink
Browse files

Use shorter names.

  • Loading branch information...
davidw committed Mar 19, 2013
1 parent a7b056f commit a1c5eca5738e0d6adf54fde7925000af1ba94f5d
Showing with 10 additions and 10 deletions.
  1. +3 −3 README_DATABASE
  2. +7 −7 src/boss/boss_migrate.erl
View
@@ -112,7 +112,7 @@ Database Migrations
Chicago Boss supports Rails-like database migrations, which work like so:
- > boss_migrate:make_migration(your_app_name, create_some_table).
+ > boss_migrate:make(your_app_name, create_some_table).
This creates a file in priv/migrations/ with a name like 1363463613_create_some_table.erl
@@ -128,12 +128,12 @@ Edit this file in order to do something along these lines:
To actually run the migrations, you'd do
- > boss_migrate:run_migrations(gsd_web).
+ > boss_migrate:run(gsd_web).
You can also redo the last migration - which is useful when you're
developing and perhaps haven't got the table definition quite right:
- > boss_migrate:redo_migration(gsd_web, create_some_table).
+ > boss_migrate:redo(gsd_web, create_some_table).
Internally, migrations are tracked in a table called
"schema_migrations" which is automatically created and managed by
View
@@ -3,28 +3,28 @@
-module(boss_migrate).
--export([make_migration/2,
- run_migrations/1,
- redo_migration/2]).
+-export([make/2,
+ run/1,
+ redo/2]).
%% Returns a sorted list of all files in priv/migrations/.
migration_list(App) ->
lists:sort(filelib:wildcard(filename:join([boss_files:root_priv_dir(App), "migrations", "*.erl"]))).
%% Create a migration. MigrationName is an atom to use as the name of
%% the migration.
-make_migration(App, MigrationName) when is_atom(MigrationName) ->
+make(App, MigrationName) when is_atom(MigrationName) ->
{MegaSeconds, Seconds, _Microsecs} = erlang:now(),
Filename = filename:join([boss_files:root_priv_dir(App), "migrations",
io_lib:format("~p~p_~s.erl", [MegaSeconds, Seconds, MigrationName])]),
file:write_file(Filename, io_lib:format("%% Migration: ~p~n~n{~p,~n fun(up) -> undefined;~n (down) -> undefined~n end}.~n", [MigrationName, MigrationName])).
%% Run the migrations.
-run_migrations(App) ->
+run(App) ->
boss_db:migrate(load_migrations(App)).
-% Redo {down, up} a specific migration.
-redo_migration(App, Tag) ->
+ % Redo {down, up} a specific migration.
+redo(App, Tag) ->
Fun = proplists:get_value(Tag, load_migrations(App)),
boss_db:transaction(fun () ->
boss_db:migrate({Tag, Fun}, down),

0 comments on commit a1c5eca

Please sign in to comment.