• Bubble
  • Bubble
  • Line
New Blog System
Andrei Clinciu Article AUthor
Andrei Clinciu
  • 2018-03-05T12:05:00Z
  • 2 min to read

Once upon a time a software developer began to implement his own version of a blog.

 

This website has been 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 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

I've did this multiple times.

 

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..

 

Ideas and comments

Andrei Clinciu
Andrei Clinciu

I'm a Full Stack Software Developer specializing in creating websites and applications which aid businesses to automate. Software which can help you simplify your life. Let's work together!

Building Great Software
The digital Revolution begins when you learn to automate with personalized software.

Find me on social media