harness-drone/store/shared/migrate
Eoin McAfee d7e34af1de
(bug) - fix original template scripts & remove amend scripts (#3229)
* removing amend template scripts and fixing original scripts due to Brads feedback
2022-06-15 09:11:28 +01:00
..
mysql Feature/dron 101 cards 2 (#3158) 2021-10-26 08:10:01 +01:00
postgres (bug) - fix original template scripts & remove amend scripts (#3229) 2022-06-15 09:11:28 +01:00
sqlite (bug) - fix original template scripts & remove amend scripts (#3229) 2022-06-15 09:11:28 +01:00
README.md (feat) adding depends_on, image and detached fields to step 2021-06-22 13:57:04 +01:00

Building SQL DDL into Drone

These folders contain the code for the different of databases that drone can use. They contain the SQL necessary to create the necessary tables and migrate between versions (IE the DDL). This SQL is generated into a go file and included as part of the Drone binary.

Making a changes to the database DDL

Any new changes to the database structure are always put into a new SQL file. Follow the naming scheme in the store/shared/migrate/<db>/files of the SQL files by incrementing the number file name and give it a good description of what changes are being made.

Changes will need to be implemented for all supported databases, making similar changes for eg Mysql/Postgres/Sqllite.

NB Any changes to the database structure will need to be reflected for the relevant struct in the core directory. Changing the objects in the store directory for the ORM. Finally Possibly in the repositories github.com/drone/drone-go and github.com/drone/runner-go.

Generating Go from the SQL files

To generate the go files you will need to install the golang command line tool Togo so it is on your users PATH.

Steps to install Togo

# in your workspace
git clone git@github.com:bradrydzewski/togo.git
cd togo
go get github.com/bradrydzewski/togo

Generating go DDL

Enter the desired database's implementation folder, and run the following. It will update the ddl_gen.go file.

go generate