TodoList implementation using PostgreSQL
Swift
Latest commit 773cce6 Jan 16, 2017 @tfrank64 tfrank64 one more readme update

README.md

TodoList PostgreSQL

Build Status Swift 3.0.2

Quick start:

  1. Download Swift 3

  2. Download PostgreSQL You can use brew install postgresql

  3. Clone the TodoList PostgreSQL repository git clone https://github.com/IBM-Swift/todolist-postgresql

  4. Compile the library with swift build -Xcc -I/usr/local/include -Xlinker -L/usr/local/lib or create an XCode project with swift package generate-xcodeproj

  5. Open the project

  6. Change static let defaultPostgreHost = "/var/run/postgresql" to static let defaultPostgreHost = "localhost" & Change static let defaultPostgreUsername = "travis" to static let defaultPostgreUsername = "INSERT_OWN_DEFAULT_USERNAME"

    Note: To see your own default username, do psql --help

  7. Run the test cases with swift test or directly from XCode

Setting up Swift application in Bluemix

  1. Get an account for Bluemix and go to Category called Compute

    Postgresql

  2. Then click the blue hexagon '+' icon on the top right corner

    Postgresql

  3. Look under the category of "Runtime" and click "Swift application"

    Postgresql

  4. Enter the app name as: todolist-postgresql and then create the application

    Postgresql

Setting up PostgreSQL service in Bluemix

  1. Go to Bluemix homepage and click on the Category called Compute

    Postgresql

  2. Then click the blue hexagon '+' icon on the top right corner

    Postgresql

  3. Click "View all" on the top left corner, so it will show all categories

    Postgresql

  4. Search for Postgresql by Compose

    Postgresql

  5. Bound your Swift application to your Postgresql Service, create an account for Compose, and access your credentials from Compose and input it to Postgresql service.

    Postgresql

  6. Upon creation, you should see your unbound service on the dashboard page

    Postgresql

  7. SSH to the server and enter your password credentials (i.e)

    psql "sslmode=require host=INSERT_HOST_NAME port=INSERT_PORT_NUM dbname=compose user=admin"
  8. Once in the server, create a database called "todolist"

    create database todolist;
  9. Then create the table called "todos"

    create table todos(tid BIGSERIAL PRIMARY KEY, user_id varchar(128) NOT NULL, title varchar(256) NOT NULL, completed boolean NOT NULL, ordering INTEGER NOT NULL);
  10. To confirm if you have the table created, you can \d todos

Deploying to Bluemix:

Deploy to Bluemix Button

You can use this button to deploy TodoList to your Bluemix account, all from the browser. The button will create the application, create and bind any services specified in the manifest.yml file and deploy.

Deploy to Bluemix

Once the application is deployed, you may want to setup the database. To do that, follow steps 7-10 in the section above and you should be all setup.

Manually

  1. Dowload and install the Cloud Foundry tools:

    cf login
    bluemix api https://api.ng.bluemix.net
    bluemix login -u username -o org_name -s space_name
    
    Be sure to change the directory to the todolist-postgresql directory where the manifest.yml file is located.
    
  2. Run cf push

  3. It should take several minutes, roughly 4-6 minutes. If it works correctly, it should state

    2 of 2 instances running
    App started