README.md

 1Make sure to use git clone --recursive on this repository to get the submodule. See [here](https://github.com/pg-redis-fdw/redis_fdw)
 2for instructions on installing the Redis foreign data wrapper. See [here](https://github.com/postgis/postgis/blob/master/README.postgis) for instructions on installing PostGIS.
 3In both cases you can also check your systems package repositories.
 4
 5    sudo apt install postgresql-11 postgresql-client
 6    sudo -u postgres psql
 7    CREATE DATABASE jmp;
 8    GRANT ALL ON DATABASE jmp TO unix_user;
 9    GRANT CREATE ON SCHEMA public TO unix_user;
10    \c jmp
11    CREATE EXTENSION btree_gist;
12    CREATE EXTENSION citext;
13    CREATE EXTENSION pgcrypto;
14    CREATE EXTENSION redis_fdw;
15    CREATE EXTENSION postgis;
16    CREATE SERVER redis_server
17        FOREIGN DATA WRAPPER redis_fdw
18        OPTIONS (
19          address '127.0.0.1',
20          port '6379'
21    );
22    GRANT USAGE ON FOREIGN SERVER redis_server TO unix_user;
23    CREATE USER MAPPING
24        FOR PUBLIC
25            SERVER redis_server
26            OPTIONS (user 'default');
27
28    exit
29    sudo apt install sqitch
30    cd schemas
31    sqitch deploy
32    bundle install --path=.gems
33    cp config.dhall.sample config.dhall
34    $EDITOR config.dhall # Set up appropriately for local prosody, braintree, etc
35    bundle exec ruby sgx_jmp.rb ./config.dhall
36
37
38## Helpful keys for registration
39
40If you want to register with the backend without going through braintree or electrum, you can set the following two keys in Redis:
41
42	SET "jmp_customer_id-<USER>\\40<DOMAIN>@cheogram" 0001
43	SET "jmp_customer_jid-0001" "jmp_customer_id-<USER>\\40<DOMAIN>@cheogram"
44
45Where cheogram is whatever the component is called, and 0001 is whatever you want the user's customer ID to be.
46
47And then in psql:
48	INSERT INTO plan_log (customer_id, plan_name, date_range) VALUES ('0001', 'plan_name', tsrange('1990-01-01', '2023-01-01'));
49
50These together will ensure that the customer already has an ID, and so braintree doesn't need to be asked to create one, and the plan is activated, so we don't need to attempt to accept payment.
51
52Then when you run "register" from cheogram, it will skip right to the end and allow you to begin routing to this component.