GithubHelp home page GithubHelp logo

linlin2018 / yeti-web Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yeti-switch/yeti-web

0.0 0.0 0.0 8.22 MB

Yeti admin interface

Home Page: https://yeti-switch.org/demo.html

Ruby 85.02% Makefile 0.11% JavaScript 0.46% CoffeeScript 0.02% CSS 0.02% HTML 0.55% Python 0.01% PLpgSQL 13.43% Shell 0.02% Dockerfile 0.15% SCSS 0.14% Jinja 0.09%

yeti-web's Introduction

Welcome to YETI

Tests

Coverage Status

Contributing, Development setup

Ruby

You have to use Ruby version 2.6 with installed bundler.

Postgresql

It is strongly recommended to use PostgreSQL version 13. The easiest way to install it - is to use Debian Linux and follow official PostgreSQL instruction https://www.postgresql.org/download/linux/debian/

You need to install:

curl http://pkg.yeti-switch.org/key.gpg | sudo apt-key add -
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc	| sudo apt-key add -
sudo add-apt-repository "deb http://pkg.yeti-switch.org/debian/buster unstable main"
sudo add-apt-repository "deb http://deb.debian.org/debian buster main buster non-free"
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main"
sudo apt-get install postgresql-13 postgresql-contrib-13 postgresql-13-prefix postgresql-13-pgq3 postgresql-13-pgq-ext postgresql-13-yeti postgresql-13-pllua
sudo apt-get install -t buster-pgdg libpq-dev

In addition you need to compile or install from .deb package Yeti PostgreSQL extension postgresql-13-yeti https://github.com/yeti-switch/yeti-pg-ext

Preparing yeti-web application

Fork and clone yeti-web repository and run:

bundle install

Then create config/database.yml, example is config/database.yml.development. Notice this project uses two databases main "yeti" and second database "cdr"

Then create config/yeti_web.yml, example is config/yeti_web.yml.development.

To disable the creation of new versions via paper_trail for some model please fill the array under key versioning_disable_for_models in the config/yeti_web.yml

Сreate config/policy_roles.yml, example is config/policy_roles.yml.distr or disable policy feature by changing following lines in config/yeti_web.yml:

role_policy:
  when_no_config: allow
  when_no_policy_class: allow

And run command to create development database:

RAILS_ENV=development bundle exec rake db:create db:structure:load db:migrate
RAILS_ENV=development bundle exec rake db:second_base:create db:second_base:structure:load db:second_base:migrate
RAILS_ENV=development bundle exec rake db:seed

Then start rails server bundle exec rails s and login to http://localhost:3000/ with login admin and password 111111

Then prepare test database(do not use db:test:prepare).

RAILS_ENV=test bundle exec rake db:drop db:create db:structure:load db:migrate
RAILS_ENV=test bundle exec rake db:second_base:drop:_unsafe db:second_base:create db:second_base:structure:load db:second_base:migrate
RAILS_ENV=test bundle exec rake db:seed

This project has CDR-database, configured as SecondDatabase https://github.com/customink/secondbase And all commands should be run explicitly by calling "db:second_base:*" commands.

NOTICE: Test DB needs seeds, actually only PGQ seed.

And run tests:

bundle exec rspec

Migrations

When you run several migrations in a row, you may wish to stop at some point. In this case you should add stop_step method to the migration:

# example /db/migrate/20171105085529_one.rb
def change
  # do something
end

def stop_step
  true
end

In this case all migrations after this one will no be performed. To continue migration process you should run rake db:migrate command again.

If you do not want to migrate with stops, use env-variable IGNORE_STOPS=true

IGNORE_STOPS=true bundle exec rake db:migrate

Migrations that insert rows into yeti database

RAILS_ENV=test bundle exec rake db:create db:structure:load
RAILS_ENV=test bundle exec rake db:second_base:create db:second_base:structure:load
RAILS_ENV=test bundle exec rake db:seed
# create migration inside db/migrations
RAILS_ENV=test bundle exec rake db:migrate
# SCHEMA_NAME - schema of table into which you've inserted row(s)
# YETI_TEST_DB_NAME - yeti test database name on local machine
pg_dump --column-inserts --data-only --schema=sys --file=db/seeds/main/SCHEMA_NAME.sql YETI_TEST_DB_NAME

Use Docker Postgres for development

For development purpouse it is convinient to use PostgreSQL from Docker image. Here is the instruction how to set it up-and-running:

  • Install Docker(Ubuntu example)

    Install Docker on Ubuntu 18.10

  • Run following commands in terminal from yeti-web projects directory

    sudo docker build -t yeti_postgres -f ci/pg13.Dockerfile .
    
  • Start the Postgres Server using docker image, with remapped port to 3010 and volume "yetiPgData" to persist data after docker container stops:

    sudo docker run -p 3010:5432 --volume yetiPgData:/var/lib/postgresql yeti_postgres
    
  • Update config/database.yml with

    username: postgres
    password:
    port: 3010
  • Initialize database with instructions described in Contributing, Development setup section(db:create, db:structure:load, etc.)

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.