Skip to content

Commit

Permalink
fix: add note for plural table name in migration scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sytranvn committed Oct 1, 2024
1 parent ed99716 commit 5851707
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions versioned_docs/version-2.2.1/learn/beginner/crud-application.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ For the Todo API, we need two tables, Users and Todos, let's edit the migrations
To create the users table, navigate to the `db/migrations` directory and edit `001.do.sql` file, and add the schema below:

```sql
CREATE TABLE IF NOT EXISTS User (
CREATE TABLE IF NOT EXISTS Users (
id INTEGER PRIMARY KEY,
username TEXT NOT NULL UNIQUE,
password TEXT NOT NULL,
Expand All @@ -60,13 +60,16 @@ CREATE TABLE IF NOT EXISTS User (
And let's edit the `migrations/001.undo.sql` file to look like this:

```sql
DROP TABLE User;
DROP TABLE Users;
```
:::note
To ensure the OpenAPI specification accurately reflects your API endpoints, it's essential to use plural table names.
:::

Before we apply the migrations, let's create a new table for our Todos, to do that create another file `002.do.sql` and inside it, add the schema for your Todos table.

```sql
CREATE TABLE IF NOT EXISTS Todo (
CREATE TABLE IF NOT EXISTS Todos (
id INTEGER PRIMARY KEY,
user_id INTEGER,
title TEXT NOT NULL,
Expand All @@ -79,7 +82,7 @@ CREATE TABLE IF NOT EXISTS Todo (
And again, add a new file `002.undo.sql` to drop the table.

```sql
DROP TABLE Todo;
DROP TABLE Todos;
```

:::note
Expand Down Expand Up @@ -118,4 +121,4 @@ You should get a **200 OK** status code for a successful request.

## Conclusion

Congratulations! You have successfully created a simple Todo API using Platformatic. This tutorial covered the basics of setting up a Platformatic project, defining a schema, configuring the service, and creating API endpoints. For more advanced features and configurations, refer to the [Platformatic API Documentation](../../cli.md).
Congratulations! You have successfully created a simple Todo API using Platformatic. This tutorial covered the basics of setting up a Platformatic project, defining a schema, configuring the service, and creating API endpoints. For more advanced features and configurations, refer to the [Platformatic API Documentation](../../cli.md).
Binary file modified versioned_docs/version-2.2.1/learn/images/plt-endpoints.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5851707

Please sign in to comment.