Configure Postgre


#1

I have found all the sql scripts you have inside your projects.
I also have created a postgre database.
Is there any way I can run all the schema creation script at once?
Also where do I put the configuration file?(You say in the documentation that it must be named dbtoolcontext-example-postgres-fin.properties)

Thank you.


#2

If you have an empty Postgres database and want to populate it for the examples server (on 2.1) you can run ExampleDatabaseCreator to setup to populated database. The file toolcontext-examplessimulated-postgres.properties can be used to setup the parameters needed.

In summary, run the ExampleDatabaseCreator class with the arguments -Dlogback.configurationFile=com/opengamma/util/warn-logback.xml classpath:/toolcontext/toolcontext-examplessimulated-postgres.properties

If you have a checked out and built source, you can also use maven:

mvn opengamma:server-init -Dconfig=fullstack
mvn opengamma:server-run -Dconfig=fullstack

But you would need to edit the config files in the fullstack config directory to setup postgres (as by default they point at HSQL).


#3

Hi,

I have a similar question. I found the sql scripts here:

However, I’m not running the example and I’m not running the server either. I’m just using the client in my own application. I’m not sure which scripts I need, so I started running them manually one-by-one starting from a blank PostgreSQL database (pats self on back for getting psql up and running). The first several scripts were fine, but I noticed errors when I ran “rsk” (there may have been errors earlier, but that was the first I found). This made me wonder if the order of the scripts matter. Does the order matter?

If the order matters, what is the correct order to run the scripts to set up the database?

On the page

I found the following line:

  • db.schemaNames = cfg,eng,exg,pos,prt,sec,snp,usr,org

Does this imply a particular order?

Observations:

  • I don’t see a script for “eng” at the postgres link above. What is it? Is it needed? If needed, where is it?
  • The postgres link above has two scripts not mentioned on the Db Connection Config link: hts and rsk. What are these? Are they needed?

If it helps, I dropped all tables/sequences and started fresh with “rsk”. The script runs fine until it creates rsk_run:

coherent=# create table rsk_run (
coherent(#     id bigint not null,
coherent(#     version_correction varchar(255) not null,
coherent(#     viewdef_scheme      VARCHAR(255) NOT NULL,
coherent(#     viewdef_value       VARCHAR(255) NOT NULL,
coherent(#     viewdef_version     VARCHAR(255),
coherent(#     live_data_snapshot_id bigint not null,
coherent(#     create_instant timestamp without time zone not null,
coherent(#     start_instant timestamp without time zone not null,       -- can be different from create_instant if is run is restarted
coherent(#     end_instanttimestamp without time zone,
coherent(#     valuation_time timestamp without time zone not null,
coherent(#     num_restarts int not null,
coherent(#     complete boolean not null,
coherent(#     primary key (id),
coherent(#     constraint rsk_fk_run2live_data_snapshot
coherent(#             foreign key (live_data_snapshot_id) references rsk_live_data_snapshot (id),    
coherent(#     constraint rsk_chk_uq_run unique (id, version_correction, viewdef_scheme, viewdef_value, viewdef_version, live_data_snapshot_id)
coherent(# );
ERROR:  syntax error at or near "time"
LINE 13:     end_instanttimestamp without time zone,

Any idea what I might be doing wrong?

Thank you.

Best regards,
Eric


#4

That was a little odd. I was cringe copying and pasting into the psql command line. The separator between end_instant and timestamp is a tab instead of space. When I paste it, apparently the tab disappeared.

Edit: PS: I switched to pgAdmin and was able to load all sql scripts with no problems now. The order does not seem to matter.