-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdbMigrationInstructions.txt
54 lines (34 loc) · 1.53 KB
/
dbMigrationInstructions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
For create new database table
1. goto project src folder
command - cd src
2. create table model
command - npx sequelize-cli model:generate --name YourTableName --attributes ColumnName:Datatype
example - npx sequelize-cli model:generate --name User --attributes firstName:string,lastName:string,email:string
3. next run following command
command - npx sequelize-cli db:migrate
4. Then replace scr-database folder schedule.sqlite3 to root folder database folder.
5. npx sequelize-cli db:seed:all
-- Data Types
i. STRING
ii. INTEGER
iii. TEXT
for further details refer - https://sequelize.org/master/manual/migrations.html
-------------------------------------------------------------------------------------------------------
To change column name in database
This may help you, follow this steps
Step 1: npm install -g sequelize-cli To install sequelize command line tool
Step 2: sequelize migration:create --name rename-column-tour_title-to-tour_name-in-tabelname
Step 3: Open newly created migration file and add below code
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.renameColumn('tableName', 'tour_title', 'tour_name');
},
down: (queryInterface, Sequelize) => {
return queryInterface.renameColumn('tableName', 'tour_name', 'tour_title');
}
};
Step 4: in command line run this below command
sequelize db:migrate
Now your column name changed successfully.
---------------------------------------------------------------------------------------------------------