Skip to content

Levure Configuring a Levure application

Trevor DeVore edited this page Nov 28, 2018 · 6 revisions

Adding SQL Yoga to a Levure application

The SQL Yoga repo includes the necessary files to work as a Helper in the Levure framework. Using SQL Yoga with Levure simplifies configuration and development work.

Add as a helper

The simplest way is to download the SQL Yoga repository, rename the folder to "sql yoga" and place it in your applications "helpers" folder. The next time you open your application in the IDE SQL Yoga will be loaded.

Configure app.yml

In the app.yml file you tell SQL Yoga where to find your database configuration files and the name of the database object that will be created. Add the following to the app.yml file.

app.yml

sql yoga:
  configuration:
    - filename: ./database
      database key: default

Create the database folder

Since you told SQL Yoga that configuration files are stored in a database folder you now need to create the folder. Create the database folder in the app folder (alongside the ui, behaviors, etc. folders).

Configuring SQL Yoga

When your app is opened up in the IDE the SQL Yoga helper will look for any YAML files in the configuration folder, load them into memory, convert them into a LiveCode array, and then pass that array to dbobject_initialize.

You can configure the following objects in the YAML files:

  • connections
  • tables
  • relationships
  • scopes
  • sql query templates

You can split up different objects into different YAML files for the sake of readability. One approach is to create a connections.yml, table objects.yml, and query templates.yml. The table objects.yml file can define tables, relationships, and scopes.

Create the connections.yml file

In the ./app/database folder create a file named connections.yml. Configure a connection that points to the database file. Here is a SQLite example that points to a .sqlite file in the ./app/database folder:

default connection: local
connections:
  local:
    adaptor: sqlite
    file: ./database/to-do.sqlite

Creating tables, relationships, and scopes

In the ./app/database folder create a file named table objects.yml. You will add YAML for configuring any table, relationship, and scope objects to this file.

Clone this wiki locally