New Blog System

Show table of contents

As you may have noticed there was a slight change in how the blog looks and feels.

It wasn't random, this is a new blog written from scratch. I know that it kind of misses the main point of Wheel Reinvention, however it was for a noble cause; mastering Phoenix!

I've also switched from hosting provider and mail provider for multiple domains. No downtime occured, however due to DNS propagation weird happened but it's now been solved.

I'm now officially using Linode.com for VPS/HOSTING and Mxroute.com for e-mail accounts in all of my personal projects. Also in most of my client projects unless otherwise required.

I set a challenge for myself to build a fully functional blog/cms system with Phoenix+Elixir. The challenge was to use small libraries instead of huge CSS/JavaScript/HTML frameworks.

In 3 days I had a fully working prototype.

So i moved all my posts manually from my old BLOG. Yes I know, i could have imported everything automatically with a script. But why bother to fiddle with wordpress?

There is another very important reason WHY i decided to do everything in one run. GDPR compliance exercise. GDPR is nearing in 25 may 2018. By developing everything myself I can be sure that If I start offering certain services via my website that I can be 100% GDPR compliant and not have to wait for other software creators to provide this compliance.
I know that the GDPR does not apply to the processing of personal data in the following case: (c) by a natural person in the course of a purely personal or household activity. Thus this blog.

Features:

  • Elixir and Phoenix
  • User authentication and authorization (basic)
  • Tags Management (pure JavaScript)
  • Pure CSS
  • Vanilla Plain Pure JavaScript implementation
  • CKEditor for Post management
  • Blog/CMS style pages

It's still work in progress. More updates will come.

 

Certain Pitfalls of switching SQL database - Ecto - SQLite - PostgreSQL -

For the development I used SQLite but I've switched it to PostgreSQL. Thanks to Ecto the app won't feel anything and I won't have to change much.

Well, if SQLIte doesn't care what you put in columns, PostgreSQL does and gives you errors and big headaches.

One of the main ones was  that some ECTO things that worked in SQLITE did no longer work in PostgreSQL. However I changed the code to use upsert.

Another annoying error was:

 ** (Ecto.ConstraintError) constraint error when attempting to insert struct:

    * unique: posts_pkey

 

I still don't understand why this occured, but looking at the  SQL  i saw this:

  id bigint NOT NULL DEFAULT nextval('posts_id_seq'::regclass),

However it seemed NOT TO EXIST. WTF? Did  Phoenix forget to add it when I created a migration?

 

The solution:

select setval('posts_id_seq'::regclass,  (SELECT MAX(id) from "posts")) 

 

However that DID only solve the problem partially , all my other tables like users, etc had the same issue.

 

Another big problem was that the Tags functionality broke. Adding a new post added the tags but didn't make the connection.

NOTE TO SELF: Don't switch database type in the middle of a project..

 

Subscribe to my newsletter


What are your thoughts?

All comments are moderated and must adhere to the terms of service.

You might enjoy these similar articles:

Subscribe to my newsletter!