Setup Gobierto Data for development

Steps to setup Gobierto Data:

  1. Create a new database to store the datasets, in the console you can run:
createdb gobierto_data -U postgres
# for remote server or dockerized postgres use:
createdb -h 127.0.0.1 -p 5432 gobierto_data -U postgres
  1. Enable the module Gobierto Data in the site configuration

  2. Edit the module Gobierto Data configuration and use this database config:

Use this configuration:

{
  "read_db_config": {
    "host": "localhost",
    "adapter": "postgresql",
    "database": "gobierto_data",
    "encoding": "unicode",
    "password": "",
    "username": "postgres"
  },
  "read_draft_db_config": {
    "host": "localhost",
    "adapter": "postgresql",
    "database": "gobierto_data",
    "encoding": "unicode",
    "password": "",
    "username": "postgres"
  },
  "write_db_config": {
    "host": "localhost",
    "adapter": "postgresql",
    "database": "gobierto_data",
    "encoding": "unicode",
    "password": "",
    "username": "postgres"
  }
}
  1. Generate admins primary api tokens
bin/rails c
>  GobiertoAdmin::Admin.all.each(&:primary_api_token!)
  1. Get an admin token, visiting Users > Admin (for example, Natasha's token)

  2. Load some data in the tables (having madrid.gobierto.test as your site)

curl  -XPOST 'http://madrid.gobierto.test/api/v1/data/datasets' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer TOKEN' \
--data-raw '{
    "data": {
        "type": "gobierto_data-dataset_forms",
        "attributes": {
            "name": "Contracts dataset",
            "table_name": "contratos",
            "visibility_level": "active",
            "data_path": "https://gobierto-public-resources.s3.amazonaws.com/sample_dataset/sample_contracts_dataset.csv"
        }
    }
}'

  1. Enjoy http://madrid.gobierto.test/datos/contracts-dataset/editor

What’s Next

Read more about Gobierto Data