Skip to content

Commit

Permalink
Move dev database to localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
Vagrant committed Aug 12, 2019
1 parent 5856450 commit fb902e9
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
9 changes: 9 additions & 0 deletions .sentry.yml
@@ -0,0 +1,9 @@
---
display_name: netblog
shard_name: netblog
install_shards: false
info: true
build: crystal build --warnings all ./src/netblog.cr -o ./bin/netblog
run: ./bin/netblog
watch: ["./src/*.cr", "./src/**/*.slang", "./public/images/*.png"]
colorize: true
2 changes: 1 addition & 1 deletion bin/micrate
Expand Up @@ -3,6 +3,6 @@ require "micrate"
require "pg"

#Micrate::DB.connection_url = ENV["DATABASE_URL"]
Micrate::DB.connection_url = "postgresql://dbuser:dbuser@dbserver:5432/netlog"
Micrate::DB.connection_url = "postgresql://dbuser:dbuser@localhost:5432/netlog"
Micrate::Cli.run

6 changes: 4 additions & 2 deletions db/migrations/20180625154321_create_entry_table.sql
@@ -1,10 +1,12 @@
-- +micrate Up
-- SQL in section 'Up' is executed when this migration is applied
CREATE TABLE entries(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
id BIGSERIAL PRIMARY KEY,
category VARCHAR NOT NULL,
memo TEXT NOT NULL,
entry_date DATETIME NOT NULL
entry_date VARCHAR NOT NULL,
created_at TIMESTAMPTZ,
updated_at TIMESTAMPTZ
);


Expand Down
2 changes: 1 addition & 1 deletion shard.lock
Expand Up @@ -18,7 +18,7 @@ shards:

kemal:
github: kemalcr/kemal
version: 0.25.2
version: 0.26.0

kemal-flash:
github: neovintage/kemal-flash
Expand Down
6 changes: 3 additions & 3 deletions shard.yml
@@ -1,5 +1,5 @@
name: netblog
version: 0.14.2
version: 0.15.1
description: |
A simple browser interface to maintenance log, netlog.db.
Expand All @@ -10,7 +10,7 @@ targets:
netblog:
main: src/netblog.cr

crystal: 0.29.0
crystal: 0.30.0

license: MIT

Expand All @@ -23,7 +23,7 @@ dependencies:
version: ~> 0.16.0
kemal:
github: kemalcr/kemal
version: ~> 0.25.0
version: ~> 0.26.0
slang:
github: jeromegn/slang
kemal-flash:
Expand Down
4 changes: 2 additions & 2 deletions src/netblog.cr
Expand Up @@ -48,7 +48,7 @@ module Netblog
end

Kemal.config.tap do |config|
config.env = "production"
config.env = "development"
config.host_binding = resolve_ip_address
config.port = 4567
end
Expand Down Expand Up @@ -125,7 +125,7 @@ end
post "/log/:id/edit" do |env|
entry = find_record(env.params.url["id"])
if entry
entry.entry_date = Time.local.to_s("%F %T")
# entry.entry_date = Time.local.to_s("%F %T")
entry.category = env.params.body["category"]
entry.memo = Myutils.punctuate!(Myutils.capitalize!(env.params.body["memo"]))
env.flash["success"] = "Log entry successfully updated!" if save_record(entry)
Expand Down
19 changes: 14 additions & 5 deletions src/views/error500.slang
@@ -1,5 +1,14 @@
section.container-fluid.well
h2 500: Internal Server Error
p It seems like the server can't find the table it needs. Maybe go to the
a href="/maintenance" Maintenance page
| and restore the database from a current backup?
section.container-fluid.well.card
div.card-body
h2.card-title 500: Internal Server Error
p.card-text
| The 500 Internal Server Error is the general catch all error when the server
| throws an exception. Simply, the 500 Internal Server Error is a general
| http status code that means something has gone wrong on the website's server,
| but the server could not be more specific on what that exact problem is.
| Typical problems include database errors like missing or corrupt tables,
| missing environment variables, the list goes on.

p Go back to the
a href="/" Home page
| and check database integrity?

0 comments on commit fb902e9

Please sign in to comment.