Coder Social home page Coder Social logo

habit-tracker's Introduction

Habit tracker

Data Base

In this project a PostgreSQL data base is applied. In order to start data base from docker container it is required to download a PostgreSQL docker image with the command:

docker pull postgres

To start the data base run the command:

docker run --name=habbit-db -e POSTGRES_PASSWORD='qwerty' -p 5432:5432 -d --rm postgres

To create migration files run the command:

migrate create -ext sql -dir ./migrations -seq init

To make migration via the migration file run the command:

migrate -path ./migrations -database 'postgres://postgres:qwerty@localhost:5432/postgres?sslmode=disable' up

To delete tables from the data base run the command:

migrate -path ./migrations -database 'postgres://postgres:qwerty@localhost:5432/postgres?sslmode=disable' down

To enter the data base run the command:

docker exec -it 0b3c8bef7b3d /bin/bash

Then inside the postgres docker container run the command:

psql -U postgres

Inside the postgres environment, to check all the tables run the command:

\d

In case of errors with migration and db becomes dirty, enter the data base and do the next:

select * from schema_migrations;
update schema_migrations set dirty =false where version=XXXX;
Docker-compose

To start the docker compose for the first time run the command:

docker-compose -f build/docker-compose.yml up --build habit-tracker

When docker containers are built run the command without --build flag:

docker-compose -f build/docker-compose.yml up habit-tracker
TG-bot

To run the telegram-bot service run the command:

./tg-bot-habit -tg-bot-token 'token'
Testing

The project is tested with unit testing and mocks

If the code logic is changed and test mocks and test funcs need to be updated accordingly, do the following:

Mock service

In order to generate the service layer mock do the following:

  1. Open the project in the terminal

  2. Go to directory of the service layer

  3. Run the command:

go generate

This command will regenerate the mock service

  1. Check if the unit tests needs to be updated accordning to updated logic

habit-tracker's People

Contributors

aidos-dev avatar

Stargazers

Dilmurat Zairakhunov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.