commiting new changes to migrate command - sequelize-cli Nodejs - node.js

I have trouble with sequelize-cli in nodejs. suppose we define a new model with this command :
sequelize model:create --name User --attributes username:string,password:string,email:string,role:string,mobile:string
as you know this command make a migration file in migrations directory.
and with this command I can migrate my model to the database :
sequelize db:migrate
so this is ok . but what about my new changes in my model? how can I commit my new changes to database ?I need a proper way for that.
in django framework there were two basic commands :
makemigrations => for detecting new changes
migrate => for commiting to database

Just use migration:create CLI command (https://github.com/sequelize/cli) to generate new migration file and edit this file manually to make the changes you need.

Related

sequelize does not create database on local machine

I am running:
sequelize db:migrate
on my local machine and it outputs:
Sequelize CLI [Node: 15.10.0, CLI: 6.2.0, ORM: 5.8.6]
Loaded configuration file "src/db/db.config.js".
Using environment "development".
but no migration takes place on my local machine. The same code and command migrate the DB normally on a Google cloud instance. How do I debug this problem? My device is Macbook Pro running macOs High Sierra 10.13.6.
Note: the database is already created. Even when I try to delete the DB and run sequelize db:create, still nothing happens.

How to delete migrations file in django using migration command

I have an app app_blog in django project.I want to delete both migrations file with django migration command.
blog
[ ] 0001_initial
[ ] 0002_auto_20200126_0741
On your project folder do this:
./remove_migrations.sh
Then,
If you're using mysql as your db you can simply do this:
1. mysql -u root -p (To login to mysql)
2. use database foo; (foo is the name of your db)
3. DELETE FROM django_migrations; (To simply delete all migrations made)
Optionally you can specify an app name within your project when deleting myigrations for only that app like this:
3. DELETE FROM django_migrations WHERE app = app_blog
After deleting the migrations now do this in your terminal where your project resides.
python manage.py makemigrations
python manage.py migrate --fake
Then try running your local server
python manage.py runserver
Or share for someone to use it using
python manage.py runserver 0.0.0.0:8080 (8080 is the port to use)

Want Jenkins pipeline script to create docker container with test database, test against, it, destroy container

I've created a git repo for application (A) that contains a Dockerfile and docker-compose.yml that stands up a postgres database and creates and populates some tables. I use this as a support app for testing purposes during development as a disposable database.
I'd like to use this docker app in a Jenkins pipeline for testing my main application (B), which is a NodeJS app that reads and writes to the database. Application B is also in git and I want to use a Jenkins pipeline to run its tests (written in Mocha). So my overall pipeline logic would be something like this:
Triggering Event:
Code for application B is pushed to some branch (feature or master) to git.
Pipeline:
git checkout code for Application B (implicit)
git checkout code for Application A (explicitly)
cd to Application A directory:
docker-compose up -d // start postgres container
cd's to Application B directory:
npm install
npm run test (kicks off my Mocha tests that expect postgres db with localhost:5432 url)
cd to Application A directory
docker-compose down // destroy postgres container
// if tests pass, deploy application B
I'm trying to figure out the best way to structure this. I'm really checking out code from two repos: The one I want to test and build, and another repo that contains a "support" application for testing, essentially mocking my real database.
Would I use a script or declarative pipeline?
The pipeline operates in a workspace directory for application B that is implicitly checked out when the pipeline is triggered. Do I just checkout the code for Application A within this workspace and run docker commands on it?

How to create mysql databse in git lab CI/CD yaml file?

I am new gitlab CI/CD. I have created a simple yaml script to build and test my php application. I am using shared runner option available in gitlab CI.
I have specified the database name "MYSQL_DATABASE" and it doesn't seem to make any effect.
How do I specify that? Is there any other way to create database in YAML file. When I specify create database, build is getting failed stating
"/bin/bash: line 78: create: command not found".
It is hard to help without knowing more about your configuration. As user JGC already stated, the main error cause seems to be that you are trying to run create database as bash command.
If you want to create a MySQL database directly on a Linux command-line, you can use
mysql -uroot -ppassword -e "CREATE DATABASE database-name
However, with GitLab CI you should try to use one of the solutions described at https://docs.gitlab.com/ee/ci/services/mysql.html
With the Docker executor (e.g. with the SaaS version via gitlab.com) you can just use the following in your .gitlab-ci.yml:
services:
- mysql:latest
variables:
MYSQL_DATABASE: database-name
MYSQL_ROOT_PASSWORD: mysql_strong_password

Easiest way to copy/duplicate a RethinkDB database?

How can I easily duplicate my production database (mydb) to create a dev database (mydb-dev)?
The rethinkdb restore command seems to have no option to specify the name of the output database. It only has the option to select which database I'd like to restore from the dump. I'm using rethinkdb 1.16.3
You can use rethinkdb export, extract the archive, and rename the directory inside before importing it:
$ rethinkdb export
$ cd rethinkdb_export_2015-04-05T13:54:43
$ mv mydb mydb_dev
$ rethinkdb import -d ./
Thinker tool by internalfx also allows you to clone a database to a different DB, using the --targetDB= option.

Resources