# Database Deployment Via Web Console

1. Login to OpenShift web console with the given username and password.

   ![Login](https://4096465133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa3i2iCO0U9uw1JFkKW85%2Fuploads%2Fgit-blob-77cb9180546da62dc2212b84597cfec3f4cd1606%2Fdeploy-00.png?alt=media)
2. Click on **Skip tour** button.

   ![Skip tour](https://4096465133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa3i2iCO0U9uw1JFkKW85%2Fuploads%2Fgit-blob-4c058f2eb582c47912bc4607e04a147c1387d471%2Fdeploy-01.png?alt=media)
3. Click on **Create a new project** link to create a new project (a.k.a namespace).

   ![Create a new project](https://4096465133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa3i2iCO0U9uw1JFkKW85%2Fuploads%2Fgit-blob-851fb367242004dcfb5a37e6393d29d01205e13e%2Fdeploy-02.png?alt=media)
4. Enter the project name as **user*****X*****-todo** where ***X*** is the number of your username. Then click **Create** button.

   ![Enter project name](https://4096465133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa3i2iCO0U9uw1JFkKW85%2Fuploads%2Fgit-blob-8149ce951c87eb8e59238af37ee5ed4d6a39fc24%2Fdeploy-03.png?alt=media)
5. Click **Add+** menu.

   ![Add application](https://4096465133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa3i2iCO0U9uw1JFkKW85%2Fuploads%2Fgit-blob-c6d4dd42353e8a4d9792a0b6bf8b063514dfe1f9%2Fdeploy-04.png?alt=media)
6. Select **Database** in the Developer Catalog panel.

   ![Database in the Developer Catalog panel](https://4096465133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa3i2iCO0U9uw1JFkKW85%2Fuploads%2Fgit-blob-ad26c705683bfa24bf252f300b116874f4c587d2%2Fdeploy-05.png?alt=media)
7. Select **PostgreSQL** template.

   ![PostgreSQL template](https://4096465133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa3i2iCO0U9uw1JFkKW85%2Fuploads%2Fgit-blob-13e6bf34b195593fcd7b633514c7c9e00ff9f3ac%2Fdeploy-06.png?alt=media)
8. Click **Instantiate Template** button.

   ![Instantiate template](https://4096465133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa3i2iCO0U9uw1JFkKW85%2Fuploads%2Fgit-blob-171b36a73c4d91c7ab2e1e4512f4a33f55332113%2Fdeploy-07.png?alt=media)
9. Enter following input:

   * **Database Service Name:** `todo-db`
   * **PostgreSQL Connection Username:** `pguser`
   * **PostgreSQL Connection Password:** `pgpassword`
   * **PostgreSQL Database Name:** `todo`

   Then click **Create** button.

   ![Enter database details](https://4096465133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa3i2iCO0U9uw1JFkKW85%2Fuploads%2Fgit-blob-2254d87a121796dee124e0554733836f2e1584c0%2Fdeploy-08.png?alt=media)
10. Wait until the **todo-db** node is surround with blue ring then click on the node. A panel will show up on the right side, click on the **Resources** tab to see Pods and Services. Then click on the Pod name.

    ![Resources](https://4096465133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa3i2iCO0U9uw1JFkKW85%2Fuploads%2Fgit-blob-30acd471506b701fde3e78d1d8909d86b76e94cf%2Fdeploy-09.png?alt=media)
11. Go to **Terminal** tab.

    ![Open a web terminal](https://4096465133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa3i2iCO0U9uw1JFkKW85%2Fuploads%2Fgit-blob-18c241b0acab2aa520328ca31e5bcc20524045cc%2Fdeploy-20.png?alt=media)
12. Enter following command. You'll be asked to enter a password, the password is `pgpassword`.

    ```sh
    psql postgresql://todo-db:5432/todo?user=pguser
    ```

    *Example Output*

    ```sh
    psql (10.23)
    Type "help" for help.

    todo=#
    ```
13. Copy these SQL statements and paste to the terminal then press `Enter` on keyboard.

    ```sql
    drop table if exists Todo;
    drop sequence if exists hibernate_sequence;
    create sequence hibernate_sequence start 1 increment 1;
    create table Todo (
        id int8 not null,
        completed boolean not null,
        ordering int4,
        title varchar(255),
        url varchar(255),
        primary key (id)
        );
    alter table if exists Todo
        add constraint unique_title unique (title);
    INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Introduction to Quarkus', true, 0, null);
    INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Hibernate with Panache', false, 1, null);
    INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Visit Quarkus web site', false, 2, 'https://quarkus.io');
    INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Star Quarkus project', false, 3, 'https://github.com/quarkusio/quarkus/');
    ```

    *Example Output*

    ```
    todo=# drop table if exists Todo;
    NOTICE:  table "todo" does not exist, skipping
    DROP TABLE
    todo=# drop sequence if exists hibernate_sequence;
    NOTICE:  sequence "hibernate_sequence" does not exist, skipping
    DROP SEQUENCE
    todo=# create sequence hibernate_sequence start 1 increment 1;
    CREATE SEQUENCE
    todo=# create table Todo (
    todo(#        id int8 not null,
    todo(#        completed boolean not null,
    todo(#        ordering int4,
    todo(#        title varchar(255),
    todo(#        url varchar(255),
    todo(#        primary key (id)
    todo(#     );
    CREATE TABLE
    todo=# alter table if exists Todo
    todo-#     add constraint unique_title unique (title);
    ALTER TABLE
    todo=# INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Introduction to Quarkus', true, 0, null);
    INSERT 0 1
    todo=# INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Hibernate with Panache', false, 1, null);
    INSERT 0 1
    todo=# INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Visit Quarkus web site', false, 2, 'https://quarkus.io');
    INSERT 0 1
    todo=# INSERT INTO todo(id, title, completed, ordering, url) VALUES (nextval('hibernate_sequence'), 'Star Quarkus project', false, 3, 'https://github.com/quarkusio/quarkus/');
    INSERT 0 1
    ```
14. Enter this command to verify if the table was created.

    ```sh
    \dt
    ```

    *Example Output*

    ```sh
            List of relations
    Schema | Name | Type  |  Owner
    --------+------+-------+----------
    public | todo | table | pguser
    (1 row)
    ```
