initial data model implementation
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
class CreateEntries < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :entries do |t|
|
||||
t.integer :category, null: false
|
||||
t.string :fi
|
||||
t.string :en
|
||||
t.string :sv
|
||||
t.string :no
|
||||
t.string :ru
|
||||
t.string :de
|
||||
t.text :notes
|
||||
t.boolean :verified, null: false, default: false
|
||||
t.references :created_by, null: true, foreign_key: { to_table: :users }
|
||||
t.references :updated_by, null: true, foreign_key: { to_table: :users }
|
||||
|
||||
t.index :category
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,23 @@
|
||||
class CreateSuggestedMeanings < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :suggested_meanings do |t|
|
||||
t.references :entry, null: false, foreign_key: true
|
||||
t.string :language_code, null: false
|
||||
t.string :alternative_translation, null: false
|
||||
t.text :context
|
||||
t.text :reasoning
|
||||
t.string :source
|
||||
t.string :region
|
||||
t.integer :status, null: false, default: 0
|
||||
t.references :submitted_by, null: false, foreign_key: { to_table: :users }
|
||||
t.references :reviewed_by, null: true, foreign_key: { to_table: :users }
|
||||
t.datetime :reviewed_at
|
||||
|
||||
t.index :language_code
|
||||
t.index :status
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class CreateComments < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :comments do |t|
|
||||
t.references :user, null: false, foreign_key: true
|
||||
t.references :commentable, polymorphic: true, null: false
|
||||
t.text :body, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class CreateEntryVersions < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :entry_versions do |t|
|
||||
t.references :entry, null: false, foreign_key: true
|
||||
t.references :user, null: false, foreign_key: true
|
||||
t.json :changes_made, null: false
|
||||
t.string :change_type
|
||||
t.datetime :created_at, null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
class CreateSupportedLanguages < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :supported_languages do |t|
|
||||
t.string :code, null: false
|
||||
t.string :name, null: false
|
||||
t.string :native_name, null: false
|
||||
t.integer :sort_order, null: false, default: 0
|
||||
t.boolean :active, null: false, default: true
|
||||
|
||||
t.index :code, unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
class CreateUsers < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :users do |t|
|
||||
t.string :email, null: false
|
||||
t.string :password_digest, null: false
|
||||
t.string :name
|
||||
t.integer :role, null: false, default: 0
|
||||
t.string :primary_language
|
||||
t.string :invitation_token
|
||||
t.datetime :invitation_sent_at
|
||||
t.datetime :invitation_accepted_at
|
||||
t.references :invited_by, null: true, foreign_key: { to_table: :users }
|
||||
|
||||
t.index :email, unique: true
|
||||
t.index :invitation_token, unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class AddSuggestedMeaningsLanguageCodeForeignKey < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
add_foreign_key :suggested_meanings, :supported_languages,
|
||||
column: :language_code,
|
||||
primary_key: :code
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
# This file should ensure the existence of records required to run the application in every environment (production,
|
||||
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
|
||||
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
|
||||
# MovieGenre.find_or_create_by!(name: genre_name)
|
||||
# end
|
||||
Reference in New Issue
Block a user