|
|
2 years ago | |
|---|---|---|
| .. | ||
| api | 2 years ago | |
| config | 2 years ago | |
| db | 2 years ago | |
| private/attachments | 4 years ago | |
| public | 4 years ago | |
| test | 3 years ago | |
| utils | 3 years ago | |
| views | 6 years ago | |
| .editorconfig | 6 years ago | |
| .env.sample | 2 years ago | |
| .eslintignore | 3 years ago | |
| .gitignore | 3 years ago | |
| .npmrc | 6 years ago | |
| .sailsrc | 6 years ago | |
| README.md | 2 years ago | |
| app.js | 4 years ago | |
| get-config.js | 4 years ago | |
| package-lock.json | 2 years ago | |
| package.json | 2 years ago | |
README.md
Planka Server Documentation
The backend was developed using the SailsJS framework, which facilitates complex operations in web applications, especially when combined with the Knex database migration manager.
Modifying the Database Structure
Creating a Migration
Step 1: Navigate to the corresponding folder within the project:
cd ROOT_PATH/server/db
Step 2: Execute the following command to create a new migration file:
npm run db:create-migration add_change_in_the_database_structure
This command creates a file in the migration folder named based on the provided argument. The generated file will have the following initial structure:
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function(knex) {
// Add the changes that will be applied to the database
};
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function(knex) {
// Add the changes that will revert the operations done in up
};
Adapting to Asynchronous Functions:
In the project, asynchronous functions are used by default. Modify the migration file to adhere to this standard:
exports.up = async (knex) => {
// Migration logic to apply changes
};
exports.down = async (knex) => {
// Migration logic to revert changes
};
Implementation
Implement the necessary logic in the up and down methods to apply or revert changes in the database. To understand how migrations work and explore detailed examples, refer to the official Knex documentation on migrations.