Before proceeding
Ensure you install the CLI, log in to your Appwrite account, and initialize your Appwrite project.
Create and manage your tables using the CLI commands. The Appwrite CLI also helps you push your project's databases and tables schema from one project to another.
Initialize table
Create a new table using the following command:
appwrite init tables
Pull table
You can also pull your existing Appwrite tables and databases from the Appwrite Console using the pull
command in the folder containing your appwrite.config.json
file.
appwrite pull tables
appwrite.config.json
After initializing your Appwrite project and pulling your existing tables, your appwrite.config.json
file should look similar to the following:
{
"projectId": "<PROJECT_ID>",
"endpoint": "https://<REGION>.cloud.appwrite.io/v1",
"databases": [
{
"$id": "<DATABASE_ID>",
"name": "songs",
"$createdAt": "2023-07-01T18:35:27.802+00:00",
"$updatedAt": "2023-08-01T21:41:41.663+00:00",
"enabled": true
}
],
"tables": [
{
"$id": "<TABLE_ID>",
"$permissions": [
"create(\"any\")",
"read(\"any\")",
"update(\"any\")",
"delete(\"any\")"
],
"databaseId": "<DATABASE_ID>",
"name": "music",
"enabled": true,
"rowSecurity": false,
"columns": [
{
"key": "userID",
"type": "string",
"status": "available",
"error": "",
"required": false,
"array": false,
"size": 100,
"default": null
},
{
"key": "name",
"type": "string",
"status": "available",
"error": "",
"required": false,
"array": false,
"size": 100,
"default": null
},
{
"key": "cloudinaryId",
"type": "string",
"status": "available",
"error": "",
"required": false,
"array": false,
"size": 100,
"default": null
},
{
"key": "user",
"type": "string",
"status": "available",
"error": "",
"required": false,
"array": false,
"size": 100,
"default": null
},
{
"key": "audio",
"type": "string",
"status": "available",
"error": "",
"required": false,
"array": false,
"size": 200,
"default": null
},
{
"key": "genre",
"type": "string",
"status": "available",
"error": "",
"required": false,
"array": false,
"size": 500,
"default": null
},
{
"key": "artist",
"type": "string",
"status": "available",
"error": "",
"required": false,
"array": false,
"size": 500,
"default": null
}
],
"indexes": []
}
]
}
Push table
Use the push
command in the folder containing your appwrite.config.json
file to push the changes you made.
appwrite push tables
Commands
The databases command allows you to create structured tables of rows, queries, and filter lists of rows. Appwrite database CLI commands generally follow the following syntax:
appwrite databases [COMMAND] [OPTIONS]
Command | Description |
list-tables [options] | Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. |
create-table [options] | Create a new Table. Before using this route, you should create a new database resource using either a server integration API or directly from your database console. |
get-table [options] | Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. |
update-table [options] | Update a table by its unique ID. |
delete-table [options] | Delete a table by its unique ID. Only users with write permissions have access to delete this resource. |
list-columns [options] | List columns in the table. |
create-boolean-column [options] | Create a boolean column. |
update-boolean-column [options] | Update a boolean column. Changing the 'default' value will not update already existing rows. |
create-datetime-column [options] | Create a date time column according to the ISO 8601 standard. |
update-datetime-column [options] | Update a date time column. Changing the 'default' value will not update already existing rows. |
create-email-column [options] | Create an email column. |
update-email-column [options] | Update an email column. Changing the 'default' value will not update already existing rows. |
create-enum-column [options] | Create an enumeration column. The 'elements' param acts as a white-list of accepted values for this column. |
update-enum-column [options] | Update an enum column. Changing the 'default' value will not update already existing rows. |
create-float-column [options] | Create a float column. Optionally, minimum and maximum values can be provided. |
update-float-column [options] | Update a float column. Changing the 'default' value will not update already existing rows. |
create-integer-column [options] | Create an integer column. Optionally, minimum and maximum values can be provided. |
update-integer-column [options] | Update an integer column. Changing the 'default' value will not update already existing rows. |
create-ip-column [options] | Create IP address column. |
update-ip-column [options] | Update an ip column. Changing the 'default' value will not update already existing rows. |
create-relationship-column [options] | Create relationship column. Learn more about relationship columns. |
create-string-column [options] | Create a string column. |
update-string-column [options] | Update a string column. Changing the 'default' value will not update already existing rows. |
create-url-column [options] | Create a URL column. |
update-url-column [options] | Update an url column. Changing the 'default' value will not update already existing rows. |
get-column [options] | Get column by ID. |
delete-column [options] | Deletes an column. |
update-relationship-column [options] | Update relationship column. Learn more about relationship columns. |
list-indexes [options] | List indexes in the table. |
create-index [options] | Creates an index on the columns listed. Your index should include all the columns you will query in a single request. Columns can be 'key', 'fulltext', and 'unique'. |
get-index [options] | Get index by ID. |
delete-index [options] | Delete an index. |
list-table-logs [options] | Get the table activity logs list by its unique ID. |