Use PostgreSQL as default Dragonfly data store
hmans opened this issue · comments
Let's get rid of the immediate S3 dependency and make Dragonfly store its uploaded assets in the database instead.
- Re-evaluate dragonfly-activerecord, it may be good enough.
Otherwise:
- Check how well ActiveRecord copes with
bytea
columns. - If there are no immediate problems, create an AR model class to store a single asset (using
bytea
.) - Write a custom Dragonfly data store that uses this model to store the binary data, using the model ID as the Dragonfly UID.
Bonus points:
- Migrate existing data on pants.social to this new data store?
Just out of curiosity: Why not use PostgresDataStore?
It generally works fine, but has one drawback: when dealing with LOs, PostgreSQL has a native ID type (was it oid
?) to reference these, and ActiveRecord doesn't understand it (without major hackery). This may not sound like a big problem, since I could just use integer columns instead (OIDs are integer values), however: when you dump your database and then re-import that dump (think: loading a backup after a database failure), these OIDs will change. Oops! The native oid
column takes this into account and would automatically change to the new values, but of course stand-alone Integer columns would not. To cut a long story short: I would make dump-based backups unusable, and this, of course, if a big problem.
Thanks for the background information :)
@KlausTrainer @hmans Rails supports now OID data type, just do in migration:
t.column :column_name, :oid, null: false
I have not faced any problems during db backup/recovery.
@matfiz Great :) Thanks for giving notice!