You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can install the CLI tool via homebrew by executing:
138
147
```
139
148
brew tap wickwirew/wickwirew
140
149
brew install otter
@@ -150,20 +159,23 @@ This will create an `otter.yaml` configuration file. Here is where you can setup
150
159
> [!TIP]
151
160
> Follow the SQL standard and use singular table names. This will stop table structs from being named plural
152
161
153
-
#### Generating the Database
154
-
Once you have your first migration in and the project setup you can now generate the database. In the same directory where `init` was run, you run the `gen` command.
162
+
###Adding a New Migration
163
+
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
155
164
```
156
-
otter gen --output Queries.swift
165
+
otter migrations add
157
166
```
158
167
159
-
This will compile and check all migrations and queries, then generate all Swift required to talk to the database.
168
+
> [!WARNING]
169
+
> Plugin requires a clean build any time a new `sql` file is added so the input file list can be updated.
160
170
161
-
###Adding a New Migration
162
-
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
171
+
#### Generating the Database - Without Plugin
172
+
Once you have your first migration in and the project setup you can now generate the database. In the same directory where `init` was run, you run the `gen` command.
163
173
```
164
-
otter migrations add
174
+
otter generate
165
175
```
166
176
177
+
This will compile and check all migrations and queries, then generate all Swift required to talk to the database.
178
+
167
179
# Opening a Connection
168
180
Once you have your database being generated, you can now open a connection to it. Each database will automatically have a few initializers at hand to choose from. Each are listed below. When the connection is opened, all migrations are run instantly.
169
181
@@ -188,7 +200,7 @@ let database = try DB(config: config)
188
200
# Queries
189
201
All queries will be stored in the `/Queries` directory. More than one query can go in each file. To get started, create a new file in the `/Queries` directory. The cli can do this automatically. In the same directory where `init` was run, execute
190
202
```
191
-
otter queries add --name <some-name>
203
+
otter queries add <some-name>
192
204
```
193
205
194
206
Open the file that was created in `/Queries`, it should be blank. Individual queries can be defined using the the following format. At the moment a single query can only have one statement.
0 commit comments