Skip to content
Permalink
Browse files

Mapping the json type to JSONB in postgres

I made a mistake in my previous pull request by mapping the json
type to plain JSON in postgres, when it should have been JSONB.

JSONB has the advantage that values inside can be indexed and searched
very efficiently.
  • Loading branch information...
lorenzo committed Mar 26, 2016
1 parent 7c650f0 commit d67ba3f334e635c181f47a8c79b9115fed6cd154
Showing with 7 additions and 3 deletions.
  1. +1 −1 src/Database/Schema/PostgresSchema.php
  2. +6 −2 tests/TestCase/Database/Schema/PostgresSchemaTest.php
@@ -345,7 +345,7 @@ public function columnSql(Table $table, $name)
'datetime' => ' TIMESTAMP',
'timestamp' => ' TIMESTAMP',
'uuid' => ' UUID',
'json' => ' JSON'
'json' => ' JSONB'
];
if (isset($typeMap[$data['type']])) {
@@ -73,7 +73,7 @@ protected function _createTables($connection)
published BOOLEAN DEFAULT false,
views SMALLINT DEFAULT 0,
readingtime TIME,
data JSON,
data JSONB,
created TIMESTAMP,
CONSTRAINT "content_idx" UNIQUE ("title", "body"),
CONSTRAINT "author_idx" FOREIGN KEY ("author_id") REFERENCES "schema_authors" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
@@ -205,6 +205,10 @@ public static function convertColumnProvider()
'JSON',
['type' => 'json', 'length' => null]
],
[
'JSONB',
['type' => 'json', 'length' => null]
],
];
}
@@ -988,7 +992,7 @@ public function testCreateSql()
"id" SERIAL,
"title" VARCHAR NOT NULL,
"body" TEXT,
"data" JSON,
"data" JSONB,
"created" TIMESTAMP,
PRIMARY KEY ("id")
)

0 comments on commit d67ba3f

Please sign in to comment.
You can’t perform that action at this time.