Skip to content

Commit 7c87941

Browse files
author
codingphase
committed
added new categories, brands, roles, role_user table migrations
1 parent 3ee2003 commit 7c87941

5 files changed

+100
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
/** @type {import('@adonisjs/lucid/src/Schema')} */
4+
const Schema = use('Schema');
5+
6+
class CreateCategoriesSchema extends Schema {
7+
up() {
8+
this.raw(
9+
`CREATE TABLE categories(
10+
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
11+
title VARCHAR(200) NOT NULL,
12+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
13+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
14+
)
15+
`
16+
);
17+
}
18+
19+
down() {
20+
this.raw('DROP TABLE categories');
21+
}
22+
}
23+
24+
module.exports = CreateCategoriesSchema;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
/** @type {import('@adonisjs/lucid/src/Schema')} */
4+
const Schema = use('Schema');
5+
6+
class CreateBrandsSchema extends Schema {
7+
up() {
8+
this.raw(
9+
`CREATE TABLE brands(
10+
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
11+
title VARCHAR(200) NOT NULL,
12+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
13+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
14+
)
15+
`
16+
);
17+
}
18+
19+
down() {
20+
this.raw('DROP TABLE brands');
21+
}
22+
}
23+
24+
module.exports = CreateBrandsSchema;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
/** @type {import('@adonisjs/lucid/src/Schema')} */
4+
const Schema = use('Schema');
5+
6+
class CreateRolesSchema extends Schema {
7+
up() {
8+
this.raw(
9+
`CREATE TABLE roles(
10+
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
11+
title VARCHAR(200) NOT NULL,
12+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
13+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
14+
)
15+
`
16+
);
17+
}
18+
19+
down() {
20+
this.raw('DROP TABLE roles');
21+
}
22+
}
23+
24+
module.exports = CreateRolesSchema;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
/** @type {import('@adonisjs/lucid/src/Schema')} */
4+
const Schema = use('Schema');
5+
6+
class CreateRoleUserSchema extends Schema {
7+
up() {
8+
this.raw(
9+
`CREATE TABLE role_user(
10+
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
11+
role_id INT UNSIGNED NOT NULL,
12+
user_id INT UNSIGNED NOT NULL,
13+
FOREIGN KEY(role_id) REFERENCES roles(id),
14+
FOREIGN KEY(user_id) REFERENCES users(id),
15+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
16+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
17+
)
18+
`
19+
);
20+
}
21+
22+
down() {
23+
this.raw('DROP TABLE role_user');
24+
}
25+
}
26+
27+
module.exports = CreateRoleUserSchema;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@babel/plugin-proposal-decorators": "^7.1.6",
3535
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
3636
"@babel/plugin-transform-async-to-generator": "^7.1.0",
37+
"mysql": "^2.16.0",
3738
"redux": "^4.0.1",
3839
"uglify-es": "^3.3.9",
3940
"uglifyjs-webpack-plugin": "^1.3.0",

0 commit comments

Comments
 (0)