|
| 1 | +# 🚀 Quickstart: LaunchQL CLI Basics |
| 2 | + |
| 3 | +### 1. Install the CLI |
| 4 | + |
| 5 | +Make sure you have the LaunchQL CLI available: |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install -g @launchql/cli |
| 9 | +``` |
| 10 | + |
| 11 | +### 2. Initialize a workspace |
| 12 | + |
| 13 | +Generate a workspace along with its default services configuration: |
| 14 | + |
| 15 | +```bash |
| 16 | +lql init --workspace # then enter workspace name |
| 17 | +cd myworkspace |
| 18 | +``` |
| 19 | + |
| 20 | +### 3. Run Postgres locally |
| 21 | + |
| 22 | +The workspace includes a docker-compose.yml you can use to start Postgres and supporting services: |
| 23 | + |
| 24 | +```bash |
| 25 | +docker-compose up -d |
| 26 | +``` |
| 27 | + |
| 28 | +If you already have Postgres installed locally, just ensure it is running and accessible. |
| 29 | + |
| 30 | +### 4. Create a module & add changes |
| 31 | + |
| 32 | +```bash |
| 33 | +lql init |
| 34 | +cd packages/mymodule |
| 35 | + |
| 36 | +# Add schema |
| 37 | +lql add --change schemas/myschema |
| 38 | + |
| 39 | +# Add table (depends on schema) |
| 40 | +lql add --change schemas/myschema/tables/mytable --requires schemas/myschema |
| 41 | +``` |
| 42 | + |
| 43 | +### 5. Example generated SQL |
| 44 | + |
| 45 | +`deploy/schemas/myschema.sql` |
| 46 | + |
| 47 | +```sql |
| 48 | +-- Deploy: schemas/myschema to pg |
| 49 | +-- made with <3 @ launchql.com |
| 50 | +CREATE SCHEMA myschema; |
| 51 | +``` |
| 52 | + |
| 53 | +`deploy/schemas/myschema/tables/mytable.sql` |
| 54 | + |
| 55 | +```sql |
| 56 | +-- Deploy: schemas/myschema/tables/mytable to pg |
| 57 | +-- made with <3 @ launchql.com |
| 58 | +-- requires: schemas/myschema |
| 59 | + |
| 60 | +CREATE TABLE myschema.mytable ( |
| 61 | + id SERIAL PRIMARY KEY, |
| 62 | + name TEXT NOT NULL |
| 63 | +); |
| 64 | +``` |
| 65 | + |
| 66 | +### 6. Deploy to Postgres |
| 67 | + |
| 68 | +```bash |
| 69 | +lql deploy --database testdb --createdb --yes |
| 70 | +``` |
| 71 | + |
| 72 | +**Sample output highlights:** |
| 73 | + |
| 74 | +* Creates database `testdb` |
| 75 | +* Installs declared extensions (`citext`, `pgcrypto`) |
| 76 | +* Initializes migration schema |
| 77 | +* Deploys schema + table successfully |
| 78 | + |
| 79 | +``` |
| 80 | +[deploy] SUCCESS: 🚀 Starting deployment to database testdb... |
| 81 | +[migrate] SUCCESS: Successfully deployed: schemas/myschema |
| 82 | +[migrate] SUCCESS: Successfully deployed: schemas/myschema/tables/mytable |
| 83 | +[deploy] SUCCESS: ✅ Deployment complete for mymodule. |
| 84 | +``` |
| 85 | + |
| 86 | +### 7. Explore |
| 87 | + |
| 88 | +```bash |
| 89 | +lql explorer |
| 90 | +``` |
| 91 | + |
| 92 | +http://localhost:5555/graphiql (default) |
| 93 | +http://myschema.testdb.localhost:5555/graphiql (specific to a schema) |
| 94 | + |
| 95 | + |
| 96 | +### 8. Server |
| 97 | + |
| 98 | +```bash |
| 99 | +lql server |
| 100 | +``` |
0 commit comments