lewster32 / corporallancot

A Discord bot primarily for recording, searching and retrieving notes and quotes
MIT License
1 stars 2 forks source link

Implement Auto Execution of Docker SQL Scripts #13

Closed Bidthedog closed 4 years ago

Bidthedog commented 4 years ago

We can get docker to automatically run scripts (such as the SQL script generated by the ETL script we are writing for #12) when a container is first instantiated.

This can also be used to set up the "notes" table by default, though I'm not sure if we'd want to do that as the "notes" table is action specific (the !notes and !quote actions rely on it). Considering this, I think we should move the table creation into a dependency of BOTH the !notes and !quote action. This should be considered when #9 is tackled.

What do you think @lewster32? Is the auto-execution of SQL scripts actually needed here? The SQL setup script is actually a one-off, specifically for our needs in the SQS Discord channel, and not something that most people who use this bot would need.

Bidthedog commented 4 years ago

I actually think we could do with implementing the SQL script generation on the creation of the MariaDB anyway, to make local development testing and integration testing easier to handle. If we didn't, every time we recreated the docker container, we would have to manually run the SQL script we're generating with the ETL scripts.

Bidthedog commented 4 years ago

I've done this - changes were minor in the end.

Along with this branch, you will need to do the following to get the SQS notes importing into the docker MariaDB automatically when the container is created:

Note that if you have already created a MariaDB, you will need to delete it. You can do this by stopping the docker containers (docker-compose down if they are running), then deleting the mounted MariaDB persistence directory as specified in the DB_MOUNT_PATH key in your .env file. Note that this will delete all test notes you have previously added and shouldn't be done on a production environment.