Skip to content

Instantly share code, notes, and snippets.

View swanny85's full-sized avatar
🏠
Working from home

Stephen Swann swanny85

🏠
Working from home
View GitHub Profile

Migrating a SQLite3 database to PostgreSQL in a Dokku-managed environment involves several steps. This guide will walk you through the entire process, ensuring a smooth transition from SQLite3 to PostgreSQL.

Prerequisites

  • Dokku installed and running
  • PostgreSQL service set up in Dokku
  • pgloader installed on your main server
  • Access to your SQLite3 database file

Step-by-Step Guide

#!/bin/bash
for file in ????.png; do
base=$(basename "$file" .png)
mask_file="mask_${base}.png"
convert "$file" -channel R -separate "${base}_red_mask.png"
convert "${base}_red_mask.png" "$mask_file" -compose lighten -composite "${base}_combined_mask.png"
convert "$file" "${base}_combined_mask.png" -compose CopyOpacity -composite "${base}_final.png"
rm "${base}_red_mask.png" "${base}_combined_mask.png"
done

rails g scaffold inspection account:references status:string address:string

class Inspection < ApplicationRecord
  has_many_attached :inspection_pdf
  has_many :appointments, dependent: :destroy
  belongs_to :account #the company that scheduled it
end

rails g model inspection:references account:references scheduled_at:datetime