=head1 dbic-migration cheat sheet

=head2 TL;DR

 kanku dbinit

 or

 kanku dbinit --server

=head2 Preparation

 PLEASE BE AWARE: Your PERL5LIB ENV variable might result in unexpected results while testing.

 export PERL5LIB=./lib

 to avoid confusion

=head3 For production environment

 # In server mode
 export KANKU_DSN=dbi:SQLite:/var/lib/kanku/db/kanku-schema.db
 # In developer mode
 # export KANKU_DSN=dbi:SQLite:$HOME/.kanku/kanku-schema.db
 export KANKU_PATH=/opt/kanku
 export PERL5LIB=$KANKU_PATH/lib
 export SHARE_DIR=$KANKU_PATH/share

=head3 For development environment

 export KANKU_DSN=dbi:SQLite:./tmp/test.db
 export KANKU_PATH=.
 export PERL5LIB=./lib
 export SHARE_DIR=$KANKU_PATH/share

=head2 Show status of current database deployment

 dbic-migration status -S Kanku::Schema --dsn $KANKU_DSN --dir $SHARE_DIR

=head2 Create and populate a database

 cd /opt/kanku

 dbic-migration install -S Kanku::Schema --dsn $KANKU_DSN --dir $SHARE_DIR

 dbic-migration populate -S Kanku::Schema --dsn $KANKU_DSN --fixture_set install --dir $SHARE_DIR

=head2 Upgrade database

 dbic-migration upgrade -S Kanku::Schema --dsn $KANKU_DSN --database SQLite --dir $SHARE_DIR

=head2 Create a database migration

=head3 Create a test database

 dbic-migration install -S Kanku::Schema --dsn $KANKU_DSN

=head3 Populate database

 dbic-migration populate -S Kanku::Schema --dsn $KANKU_DSN --fixture_set install --dir $SHARE_DIR

=head3 Make you changes in Schema

 vi lib/Kanku/Schema/Result/*.pm

=head3 Increase $VERSION in schema

 vi lib/Kanku/Schema.pm

=head3 Create migration files

 dbic-migration prepare -S Kanku::Schema --dsn $KANKU_DSN --database SQLite --dir $SHARE_DIR

 or overwrite if already exists

 dbic-migration prepare -S Kanku::Schema --dsn $KANKU_DSN --database SQLite --dir $SHARE_DIR -O

=head3 Create install fixtures set

 dbic-migration dump_named_sets -S Kanku::Schema --dsn $KANKU_DSN --fixture_set install

=head3 Create fixtures sets

 dbic-migration -Ilib dump_all_sets --schema_class Kanku::Schema --dsn $KANKU_DSN

=head2 Recreate classes from changed database

 dbicdump -o dump_directory=./lib -o skip_load_external=1 -o debug=1 Kanku::Schema $KANKU_DSN

=cut

=head1 PATH HIRARCHIE

  /etc/kanku/			- configuration files
  /usr/bin/kanku		- cli tool
  /usr/sbin/kanku-*		- kanku daemons
  /usr/lib/kanku/lib/		- perl modules
  /usr/share/kanku/views	- MVC views (templates)
  /usr/share/kanku/public	- static content for dancer app (html/javascript/css)
  /usr/share/kanku/fixtures	- database fixtures
  /usr/share/kanku/migrations   - database migrations
  /run/kanku    		- pid files/shutdown files
  /var/lib/kanku		- variable data like database/sessions
  /var/log/kanku		- log files
  /var/cache/kanku		- cached files like downloaded images for VMs or cached git repos

