Daily Post Image from Upsplash

January: 27

Notes

keys

Need to keep track of these keys:

  • portainer_stack - Added
  • jwt_secret - Added
  • portainer - Added
  • hcaptcha - Added
  • kbve - Added
  • shieldwall - Added

Hosts

Need to extend the hosts table.

2024

  • 11:30am - Schema

    Schema

    Starting off the weekend with more schema changes! Finalize the message table and then expand out the host table, but before doing those two tables, I need to make sure the global keys are added. It seems that during the dbmodels.rs generation under the erust folder, the struct derives seem to fail, thus I need to see why it fails. The original shell uses sed to replace (Queryable, Debug, Identifiable) but since we shifted the primarykey back to serial / big int instead of binary, we no longer need the Identfiable! Thus going to remove that aspect of the schema generation.

    In addition, there would be the zod that we need to expand.

    
        export const registerUserSchema = z.object({
            username: z.string(),
            email: z.string(),
            password: z.string(),
            confirmPassword: z.string(),
            });
    
            export function registerUserSchemaValidation(schema: ZodRawShape) {
            return registerUserSchema
                .extend(schema)
                .refine((data) => data.password === data.confirmPassword, {
                message: "Passwords do not match",
                path: ["confirmPassword"],
                })
                .refine((data) => /^[a-zA-Z0-9]+$/.test(data.username) && data.username.length >= 3 && data.username.length <= 20, {
                message: "Username must be 3-20 characters long and only contain alphanumeric characters",
                path: ["username"],
                });
        }
    
    

    This is an example of the zod expansion, which is through the extend and refine functions of the zod’s ZodRawShape object.

  • 3:40pm - Refactor

    Refactor

    The worst feeling about refactoring is knowning that you have to do it a couple times over and over. Even this current refactor that I am doing right now, sadly will be done again using SQLX instead of Diesel, which is a pain to think about down the line. The main reason we would be doing the refactor again, even if we are refactoring it right now is because of the C library that Diesel depends on for MySQL.

  • 11:40pm - Drizzle

    Drizzle

    When updating Drizzle within the monorepo, we run three commands. The first command, aka ./kbve.sh -atomic drizzle kit upgrade, would be to create a new branch for the upgrade, just to make sure that nothing breaks! The second command is pnpm add drizzle-kit@latest -D and finally the third command is ./kbve.sh -reset. Finally, let us test case the studio by running ./kbve.sh -studio.

    Inside of the studio, we want to add the seven global keys that we wiped earlier, which I placed under notes as keys.