Skip to content

Levure Creating a database

Trevor DeVore edited this page Aug 1, 2018 · 2 revisions

Creating a database in a Levure application

SQL Yoga allows you to create a database from scratch using a YAML file as well.

  1. Create a migrate folder in your ./app/database folder.
  2. Create a file named 001_create_tables.yml in the ./app/database/migrate folder.
  3. Add the following YAML to the file:
migration:
  create tables:
  1. For each table you want to create add the following:
    - name: TABLE_NAME
      fields:
        - { name: FIELD_NAME, type: FIELD_TYPE }
  1. Open your Levure application open in the Livecode IDE.
  2. In the message box call sqlyogadev_runMigrations;put the result.

Your database will now have the tables and fields you specified and the ./app/database/schema.yml file will contain the new schema. If any errors occurred they will be reported in the message box due to the addition of ;put the result.

You can also create new records in the migration file.

migration:
  create tables:
    ...
  create records:
    - table: TABLE_NAME
      records:
        - { FIELD_NAME: FIELD_VALUE, FIELD_NAME: FIELD_VALUE }

Clone this wiki locally