|
7 | 7 | </p> |
8 | 8 |
|
9 | 9 | <p align="center"> |
10 | | - <strong> |
11 | | - A SQLite compiler, static analyzer and code generator for Swift ❤️ |
12 | | - </strong> |
| 10 | + <strong>A SQLite compiler, static analyzer and code generator for Swift ❤️</strong> |
| 11 | +</p> |
| 12 | + |
| 13 | +<p align="center"> |
| 14 | + <em>Just write SQL</em> |
13 | 15 | </p> |
14 | 16 |
|
15 | 17 | # Overview |
@@ -158,24 +160,39 @@ let package = Package( |
158 | 160 | #### Xcode Project Plugin Setup |
159 | 161 | For projects using an `xcodeproj` to setup the plugin it can be enabled by selecting the target and going to `Build Phases > Run Build Tool Plug-ins` and adding it to the list by selecting the plus. |
160 | 162 |
|
161 | | -## Install CLI tool |
| 163 | +## (Optional) Install CLI tool |
162 | 164 | You can install the CLI tool via homebrew by executing: |
163 | 165 | ``` |
164 | 166 | brew tap wickwirew/wickwirew |
165 | 167 | brew install puresql |
166 | 168 | ``` |
167 | 169 |
|
168 | | -Once the project has been added it is time to setup the queries and migrations folders. In the root of the project where you want everything to live, in terminal run the following command |
| 170 | +## Create a puresql.yaml Configuration |
| 171 | +In the root of the project where you want everything to live, create an `puresql.yaml` file. |
| 172 | +```yaml |
| 173 | +# puresql.yaml |
| 174 | + |
| 175 | +# The type name of the generated struct for the database |
| 176 | +databaseName: DB |
| 177 | +# Path to the directory containing the migrations |
| 178 | +migrations: Sources/Migrations |
| 179 | +# Path to the directory containing the queries |
| 180 | +queries: Sources/Queries |
| 181 | +# The path of the file to generate the Swift code into |
| 182 | +# ⚠️ This is not needed and ignored if using the plugin |
| 183 | +output: Sources/Queries.swift |
| 184 | +``` |
| 185 | +
|
| 186 | +Optionally, this can be generated automatically via the cli by running the run the following command: |
169 | 187 | ``` |
170 | 188 | puresql init |
171 | 189 | ``` |
172 | 190 |
|
173 | | -This will create an `puresql.yaml` configuration file. Here is where you can setup the project and define the directories of the migrations and queries and other project settings. |
174 | | - |
175 | 191 | > [!TIP] |
176 | 192 | > Follow the SQL standard and use singular table names. This will stop table structs from being named plural |
177 | 193 |
|
178 | | -### Adding a New Migration |
| 194 | +### Adding Your First Migration |
| 195 | +The build tool will error if it is unable to find the `/Migrations` folder defined in the `puresql.yaml` file. Make sure the folder exists and add your first migration `0.sql`. |
179 | 196 | When a new migration is needed, you can simply add a new file with a number 1 higher than the previous. To automatically do this the cli tool can do it for you by running |
180 | 197 | ``` |
181 | 198 | puresql migrations add |
|
0 commit comments