summaryrefslogtreecommitdiff
path: root/migrations/20150905232742_make_blob_fields_text.js
blob: 0ee2dbdff500f5b99de017f8fa8a65af9205cd22 (plain)
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
70
71
72
73
74
75
76
// mysqlcheck -u root --auto-repair --optimize --all-databases

exports.up = function (knex, Promise) {
  var promise;
  knex
    .raw(
      "ALTER DATABASE bucky CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci"
    )
    .then(function () {
      console.log("OK");
    });
  var sql = [
    // these ones dont workb ecause of weird unicode somewhere in the db!
    "comments comment text",
    "messages body text",
    // "invites grass tinytext",
    // "keywords threads text",
    // "keywords ops text",
    // "keywords display tinytext",
    // "tags ops text",
    // "tags display tinytext",
    "threads allowed text",
    // "threads display tinytext",
    "users grass text",
    "users keywords text",
    "users stickies text",
    // "users sink text",
    // "users display text",
    // "users boxes text",
  ].map(function (s) {
    var ss = s.split(" ");
    var sz = ["ALTER TABLE", ss[0], "MODIFY COLUMN", ss[1], ss[2]].join(" ");
    console.log(sz + ";");
    promise = knex
      .raw(
        [
          "ALTER TABLE",
          ss[0],
          "MODIFY COLUMN",
          ss[1],
          ss[2],
          "CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci",
        ].join(" ")
      )
      .then(function () {
        Promise.resolve();
        console.log("OK");
      })
      .catch(function (error) {
        console.log("error", s, error.message);
      });
  });
  return promise;
};

exports.down = function (knex, Promise) {
  return () => {};
  /*
    "comments comment blob",
    "invites grass tinyblob",
    "keywords threads blob",
    "keywords ops blob",
    "keywords display tinyblob",
    "messages body blob",
    "tags ops blob",
    "tags display tinyblob",
    "threads allowed tinyblob",
    "threads display tinyblob",
    "users grass blob",
    "users keywords blob",
    "users stickies blob",
    "users sink blob",
    "users display blob",
    "users boxes blob",
*/
};