Skip to content

Lime Project env explained

lime-project env prepare

It's very simple to scaffold a development environment, as you could se in the quick guide. But what happens under the hood when you run lime-project env prepare?

The command lime-project env prepare is a wrapper command that runs a lot of different commands, here's a brief summary about what it does:

  • It scaffolds files needed for your dev environment (Executes the command lime-project generate tool environment). Many of those files are put in a folder called .lime in the root of your solution. We recommend you to have a look in this folder after your environment is up and running. That will help you get a better understanding of the dev environment.
  • It runs poetry install (and creates a poetry.lock file if that doesn't already exist)
  • By default, it copies the backup file from the projects root folder in to .lime/backups. From v1.228.0 version of lime-project the --db-source=schema parameter can be passed to create a new database based on the schema.json file placed in the project root. The default value for --db-source is backup.
  • It sets up a docker-compose environment (It runs docker-compose up -d)
  • It restores and upgrades your Lime Database
  • It creates a search index if there's not much data in your database. Otherwise it prompts and asks if you would like to index the database.

lime-project generate tool environment

This command is automatically executed by lime-project env prepare. Thus you don't need to run it but here's a summary about what it does.

The following files are created when you run this command:

  • .env: A file with environmental variables to tell the Lime Services to use the local folder for config and static files
  • .lime: A folder containing config, logs, infrastructure info, application info and static files
  • .lime/config/config.yaml: An environmental config file
  • .vscode/launch.json - A VSCode launch config file

Info

The files in the .lime folder is autogenerated and should therefore not be commited to your repo.

Info

If you want to change the default lime-config configuration for your environment, you can manually edit the .lime/config/config.yaml file.

Restoring a database

You can restore a database using limefu.

Put a .bak file in .lime/backups/ and run

limefu database restore -b /.lime/backups/[name].bak -a [your-project-name]

Info

Your local ./lime/backups/ is mounted as a volume to the SQL Server in /.lime/backups/

Upgrading a database

You can upgrade a database using limefu.

limefu database upgrade -a [your-project-name]

During the upgrade, all database migrations are executed. Additionally, this process adds below procedures and functions in the database or replaces them, if they already exist:

Custom stored procedures - csp_lip_cc_addrelations - csp_lip_cc_createfield - csp_lip_cc_createtable - csp_lip_cc_endinstallation - csp_lip_cc_getdatastructure - csp_lip_cc_getlipsqlversion - csp_lip_cc_getlocalnames - csp_lip_cc_gettableicon - csp_lip_cc_removetablesandfields - csp_lip_cc_setfieldattributes - csp_lip_cc_settableattributes

Custom functions - cfn_fixphonenumber - cfn_getidstringbykey - cfn_gettablefromstring - cfn_lc_fixphonenumber - cfn_lc_getidstringbykey - cfn_lc_gettablefromstring

Database schema

Database schema lets you easily set up a local environment with a configuration that matches another environment. The difference between a schema and a backup file is that a schema is a plain text JSON file description of a database structure accompanied by solution configuration whereas backup (.bak) file is a binary dump of data from the database.

What is the purpose of schema?

The purpose is to represent existing database structure and configuration without any sensitive data.

By database structure and configuration we understand:

  1. limetypes - available limetypes with definitions (fields and relations) and attached policy names.
  2. policies - defined policies
  3. groups - combine members with policies and accesses
  4. config - system configuration retrieved from sys_data table (without user's configs)

All of the above are generated from the database and applied to the database without changing the content.

By sensitive data we understand any customer data like users and limeobject instances. All sensitive data is ignored during schema generation.

Endpoint

To obtain schema in a JSON format you can call /api/v1/schema endpoint. For more information check schema API docs. Downloaded schema can be provided to lime-project when preparing the local environment.

lime-project

To prepare an environment with an empty schema-based database just call the following command (available from v1.228.0):

  lime-project env prepare --db-source=schema

How to dump and load schema in dev env?

The following limefu command is used to export the schema of a database into a JSON file:

  limefu schema -a <application name> generate -f <filename>.json

Once you have a JSON file containing your database schema, you can apply it to another registered and "empty" database (only system tables and system data are allowed):

  limefu schema -a <application name> apply -f <filename>.json