This application works with dynamic tables: when you add a new field to the database, it will automatically appear in the UI. The application is displayed on a Jira global page.
See the Forge documentation for more details.
Before starting, ensure that your Forge environment is set up. Follow the Forge setup guide for instructions.
npm install./create-and-run-db.shor
export MYSQL_ROOT_PASSWORD=admin
docker run -d --name forge-sql-orm-example-db -p 3366:3306 -e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} --security-opt seccomp=unconfined --restart=always mysql
# wait 30 sec
docker exec forge-sql-orm-example-db mysql -uroot -padmin -e "create database dynamicforgesqlorm"
docker exec forge-sql-orm-example-db mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "grant all privileges on dynamicforgesqlorm.* TO 'root'@'%';"
docker exec forge-sql-orm-example-db mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "use dynamicforgesqlorm; create table users (id int not null auto_increment primary key, name varchar(200) null)"npm run models:createnpm run migration:createInstall frontend dependencies (inside static/forge-orm-example[forge-orm-example](static/forge-orm-example) directory)
npm installBuild the frontend (inside static/forge-orm-example[forge-orm-example](static/forge-orm-example) directory)
npm run buildforge registerforge deployforge install -s <environment>.atlassian.netforge webtrigger
? Select a web trigger: invoke-schema-migration
Copy your web trigger URL below to start using it:
https://c0f17555-2e0a-4c3d-ac3c-e1eb6c4b86a9.hello.atlassian-dev.net/x1/CrBtzGoiNboUxjhROYWVJa3aSm4Open the copied URL in your browser. You should see the message: 'Migrations successfully executed'.
Go to <environment>.atlassian.net and open the Forge SQL ORM Data Sync app.
- You can add users with only the
namefield initially since your table has only one column. - If you add more than one record, you can sort the table by the
namefield. - If you add two records with the same name, you can click the "Find Duplicates" button. It will display two columns:
countandname.
- If you need to add a new field (e.g.,
email), update the table structure:
export MYSQL_ROOT_PASSWORD=admin
docker exec forge-sql-orm-example-db mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "use dynamicforgesqlorm; ALTER TABLE users ADD email VARCHAR(255);"- Update migrations:
npm run migration:update- Update models:
npm run models:create- Deploy the updated app:
forge deploy- Get the new Web Trigger URL:
forge webtrigger- Open the Web Trigger URL in a browser. You should see
'Migrations successfully executed'. - Refresh the Jira app page (
<environment>.atlassian.net) to see the new columns (nameandemail). - The duplicate search feature will now work for both
nameandemailfields. - You can add as many fields as needed.
- Use
forge deployto persist code changes. - Use
forge installonly when installing the app on a new site. - Once the app is installed, any new deployments will be automatically reflected without needing to reinstall.