-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path20180519100429_Creates_Settings_Table.cfc
69 lines (63 loc) · 2.72 KB
/
20180519100429_Creates_Settings_Table.cfc
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
|----------------------------------------------------------------------------------------------|
| Parameter | Required | Type | Default | Description |
|----------------------------------------------------------------------------------------------|
| name | Yes | string | | table name, in pluralized form |
| force | No | boolean | false | drop existing table of same name before creating |
| id | No | boolean | true | if false, defines a table with no primary key |
| primaryKey | No | string | id | overrides default primary key name |
|----------------------------------------------------------------------------------------------|
EXAMPLE:
t = createTable(name='employees', force=false, id=true, primaryKey='empId');
t.string(columnNames='firstName,lastName', default='', null=true, limit='255');
t.text(columnNames='bio', default='', null=true);
t.binary(columnNames='credentials');
t.biginteger(columnNames='sinsCommitted', default='', null=true, limit='1');
t.char(columnNames='code', default='', null=true, limit='8');
t.decimal(columnNames='hourlyWage', default='', null=true, precision='1', scale='2');
t.date(columnNames='dateOfBirth', default='', null=true);
t.datetime(columnNames='employmentStarted', default='', null=true);
t.float(columnNames='height', default='', null=true);
t.integer(columnNames='age', default='', null=true, limit='1');
t.time(columnNames='lunchStarts', default='', null=true);
t.uniqueidentifier(columnNames='uid', default='newid()', null=false);
t.references("vacation");
t.timestamps();
t.create();
*/
component extends="wheels.migrator.Migration" hint="Creates Settings Table" {
function up() {
transaction {
try {
t = createTable(name='settings');
t.string(columnNames="name,description,type", default='', null=true );
t.text(columnNames="options,value,docs", default='', null=true );
t.boolean(columnNames="editable", default=true);
t.create();
} catch (any e) {
local.exception = e;
}
if (StructKeyExists(local, "exception")) {
transaction action="rollback";
throw(errorCode="1", detail=local.exception.detail, message=local.exception.message, type="any");
} else {
transaction action="commit";
}
}
}
function down() {
transaction {
try {
dropTable('settings');
} catch (any e) {
local.exception = e;
}
if (StructKeyExists(local, "exception")) {
transaction action="rollback";
throw(errorCode="1", detail=local.exception.detail, message=local.exception.message, type="any");
} else {
transaction action="commit";
}
}
}
}