forked from ChicagoBoss/ChicagoBoss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME_DATABASE
108 lines (68 loc) · 2.72 KB
/
README_DATABASE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
The Database README
===================
By default Chicago Boss uses an in-memory database, which is useful for
development and testing but not much else.
Using PostgreSQL/MySQL
----------------------
Open up boss.config and set db_adapter to `pgsql` or `mysql`. You should also set:
- db_host
- db_port
- db_username
- db_password
- db_database
Models
- - -
To use Chicago Boss with a SQL database, you need to create a table for each of
your model files. The table name should be the plural of the model name. Field
names should be the underscored versions of the model attribute names. Use
whatever data types make sense for your application.
ID fields
- - - - -
The "id" field should be a serial integer. (However, the generated
BossRecord ID exposed to your application will still have the form "model_name-1".)
Here are useful starting points for MySQL and PostgreSQL respectively:
CREATE TABLE models (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
...
PRIMARY KEY (id)
);
CREATE TABLE models (
id SERIAL PRIMARY KEY,
...
);
Counters
- - - -
To use the counter features, you need a table called "counters" with a "name"
and "value" column, like these:
CREATE TABLE counters (
name VARCHAR(255) PRIMARY KEY,
value INTEGER DEFAULT 0
);
Using Tokyo Tyrant
------------------
Tokyo Tyrant is a non-relational database developed by FAL Labs.
1. Download and install Tokyo Tyrant from <http://fallabs.com/tokyotyrant/>
2. Run Tyrant with a table database. Other database types are not supported.
3. Open up boss.config and set db_adapter to tyrant
Using Mnesia
------------
Notes:
1. The erlang VM needs a name and cookie to run Mnesia. You can set them with
the 'vm_name' and 'vm_cookie' options in boss.config.
2. Create a table for each model as well a table called '_ids_' with attributes
for [type, id, count]. For more details see
https://github.com/evanmiller/ChicagoBoss/wiki/Automatic-schema-initialization-for-mnesia
3. Open up boss.config and set db_adapter to mnesia
Using Riak (EXPERIMENTAL)
-------------------------
Riak is a NoSQL database developed by Basho Technologies.
1. Install Riak as described at http://wiki.basho.com/Installation-and-Setup.html
2. Start a Riak node with `sudo riak start`
3. Open up boss.config and set db_adapter to riak.
For query operations to work, you first need to ensure that search is enabled
in your Riak configuration:
{riak_search, [{enabled, true}]}
Then run the following command in your Riak installation for each model:
bin/search-cmd install <plural model name>
E.g. if you have a "greeting" model the command should be
bin/search-cmd install greetings