Closed Bidthedog closed 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.
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:
000-notes-table.sql
with the following contents:
CREATE TABLE IF NOT EXISTS notes (
id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
timestamp DATETIME,
user_id BIGINT(8),
channel_id BIGINT(8),
nick VARCHAR(255) NOT NULL,
message LONGTEXT NOT NULL
);
notes.sql
generated by the [ETL script[(https://gist.github.com/Bidthedog/22411b458113fdbdaf16731d56fe0232) into the .sql directory, then rename it 001-notes-import.sql
DB_SQL_SCRIPTS_MOUNT_PATH=D:/Git/Personal/corporallancot/.sql
(with the correct path on your machine) to your .env
file.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.
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.