Commit 88e65526 authored by Alex Kalderimis's avatar Alex Kalderimis

Migration: add wiki_page_meta and wiki_page_slugs

This adds two new tables, `wiki_page_slugs` and `wiki_page_meta` to hold
metadata about wiki pages.

The string limit for titles is set at our application limit, and the
slug limit is set at the maximum valid URL length.

The rule that one slug at a time may be canonical for a given page is
enforced using a unique index.

Adds changelog describing this change.
parent 17765211
---
title: Adds wiki metadata models
merge_request: 26529
author:
type: added
# frozen_string_literal: true
class AddWikiSlug < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
create_table :wiki_page_meta, id: :serial do |t|
t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false
t.string :title, null: false, limit: 255
end
create_table :wiki_page_slugs, id: :serial do |t|
t.boolean :canonical, default: false, null: false
t.references :wiki_page_meta, index: true, foreign_key: { on_delete: :cascade }, null: false
t.string :slug, null: false, limit: 2048
t.index [:slug, :wiki_page_meta_id], unique: true
t.index [:wiki_page_meta_id], name: 'one_canonical_wiki_page_slug_per_metadata', unique: true, where: "(canonical = true)"
end
end
end
......@@ -4667,6 +4667,21 @@ ActiveRecord::Schema.define(version: 2020_03_13_123934) do
t.index ["type"], name: "index_web_hooks_on_type"
end
create_table "wiki_page_meta", id: :serial, force: :cascade do |t|
t.bigint "project_id", null: false
t.string "title", limit: 255, null: false
t.index ["project_id"], name: "index_wiki_page_meta_on_project_id"
end
create_table "wiki_page_slugs", id: :serial, force: :cascade do |t|
t.boolean "canonical", default: false, null: false
t.bigint "wiki_page_meta_id", null: false
t.string "slug", limit: 2048, null: false
t.index ["slug", "wiki_page_meta_id"], name: "index_wiki_page_slugs_on_slug_and_wiki_page_meta_id", unique: true
t.index ["wiki_page_meta_id"], name: "index_wiki_page_slugs_on_wiki_page_meta_id"
t.index ["wiki_page_meta_id"], name: "one_canonical_wiki_page_slug_per_metadata", unique: true, where: "(canonical = true)"
end
create_table "x509_certificates", force: :cascade do |t|
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
......@@ -5211,6 +5226,8 @@ ActiveRecord::Schema.define(version: 2020_03_13_123934) do
add_foreign_key "vulnerability_scanners", "projects", on_delete: :cascade
add_foreign_key "web_hook_logs", "web_hooks", on_delete: :cascade
add_foreign_key "web_hooks", "projects", name: "fk_0c8ca6d9d1", on_delete: :cascade
add_foreign_key "wiki_page_meta", "projects", on_delete: :cascade
add_foreign_key "wiki_page_slugs", "wiki_page_meta", column: "wiki_page_meta_id", on_delete: :cascade
add_foreign_key "x509_certificates", "x509_issuers", on_delete: :cascade
add_foreign_key "x509_commit_signatures", "projects", on_delete: :cascade
add_foreign_key "x509_commit_signatures", "x509_certificates", on_delete: :cascade
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment