Lessons learned running svelte locally

XiaoPeng
cloud-tech
Published in
2 min readOct 22, 2019

--

I am migrating ZenUML web application from basing on a fork of web-maker to svelte. I am recording here afew lessons learned during this process.

PostgreSQL

I have PostgreSQL installed.

Login to PostgreSQL

$ psql postgrespsql (10.2)            # version of postgres
Type "help" for help.
postgres=# # the prefix gives the current database name

Which database am I currently using?

postgres=# select current_database();current_database
------------------
postgres
(1 row)
# to switch database. Note that you are NOT switch db with psql. There is no way to switch db in postgres itself. This just closes one connect and open another.postgres=# \c db_zenuml
You are now connected to database "db_zenuml" as user "pengxiao".
db_zenuml=# \connect db_zenuml
You are now connected to database "db_zenuml" as user "pengxiao".

function gen_random_uuid() does not exist

# !!! make sure you are using the correct database
db_zenuml=# CREATE EXTENSION IF NOT EXISTS pgcrypto;

pgAdmin

Set password for user postgres

postgres=# \du              # list all users
List of roles
Role name | Attributes | Member of
-----------+---------------------------------------------------
pengxiao | Superuser, Create role, Create DB | {}
postgres | Superuser, Create role, Create DB, ... | {}
zenuml | Create DB | {}
postgres=# ALTER USER postgres WITH PASSWORD 'password';

Download pgAdmiin from https://www.postgresql.org/download/ and install it. When you create a new server connection, you need the postgres user and its password. You can use other users as well.

DB migrate

When I run npm run migrate it always failed at the beginning. The migrate script is "migrate": "node-pg-migrate -r dotenv/confg" . I think they missed an up before -r . Note that -r dotenv/config may not be necessary. You should create a .env file with the following configuration:

NODE_ENV=

PORT=
BASEURL=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
MAPBOX_ACCESS_TOKEN=

PGHOST=hostname
PGPORT=port
PGUSER=username
PGPASSWORD=password
PGDATABASE=database_name

--

--