diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2024-03-13 18:03:43 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2024-03-13 18:03:43 +0100 |
| commit | a7791635aa98f012d35f97c3c5288494bbb28e38 (patch) | |
| tree | bad987e6b4d10ad2f7cd02e40658d464907595ee /db/migrate | |
| download | operum-a7791635aa98f012d35f97c3c5288494bbb28e38.tar.gz operum-a7791635aa98f012d35f97c3c5288494bbb28e38.zip | |
Initial commit
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'db/migrate')
15 files changed, 196 insertions, 0 deletions
diff --git a/db/migrate/20240224162412_create_things.rb b/db/migrate/20240224162412_create_things.rb new file mode 100644 index 0000000..5fca815 --- /dev/null +++ b/db/migrate/20240224162412_create_things.rb @@ -0,0 +1,23 @@ +class CreateThings < ActiveRecord::Migration[7.1] + def change + create_table :things do |t| + t.string :target + t.string :title, null: false, index: { unique: true } + t.string :publisher + t.string :address + t.integer :year + t.string :url + t.datetime :access + t.string :location + t.string :insideof + t.string :pages + t.references :user, null: false, foreign_key: true + t.integer :rate + t.integer :status + t.integer :kind + t.datetime :bought_at + + t.timestamps + end + end +end diff --git a/db/migrate/20240224164039_create_users.rb b/db/migrate/20240224164039_create_users.rb new file mode 100644 index 0000000..cfd4944 --- /dev/null +++ b/db/migrate/20240224164039_create_users.rb @@ -0,0 +1,10 @@ +class CreateUsers < ActiveRecord::Migration[7.1] + def change + create_table :users do |t| + t.string :username, null: false, index: { unique: true } + t.string :password_digest + + t.timestamps + end + end +end diff --git a/db/migrate/20240224165311_create_comments.rb b/db/migrate/20240224165311_create_comments.rb new file mode 100644 index 0000000..49cb989 --- /dev/null +++ b/db/migrate/20240224165311_create_comments.rb @@ -0,0 +1,10 @@ +class CreateComments < ActiveRecord::Migration[7.1] + def change + create_table :comments do |t| + t.references :thing, null: false, foreign_key: true + t.text :content + + t.timestamps + end + end +end diff --git a/db/migrate/20240224165703_create_active_storage_tables.active_storage.rb b/db/migrate/20240224165703_create_active_storage_tables.active_storage.rb new file mode 100644 index 0000000..e4706aa --- /dev/null +++ b/db/migrate/20240224165703_create_active_storage_tables.active_storage.rb @@ -0,0 +1,57 @@ +# This migration comes from active_storage (originally 20170806125915) +class CreateActiveStorageTables < ActiveRecord::Migration[7.0] + def change + # Use Active Record's configured type for primary and foreign keys + primary_key_type, foreign_key_type = primary_and_foreign_key_types + + create_table :active_storage_blobs, id: primary_key_type do |t| + t.string :key, null: false + t.string :filename, null: false + t.string :content_type + t.text :metadata + t.string :service_name, null: false + t.bigint :byte_size, null: false + t.string :checksum + + if connection.supports_datetime_with_precision? + t.datetime :created_at, precision: 6, null: false + else + t.datetime :created_at, null: false + end + + t.index [ :key ], unique: true + end + + create_table :active_storage_attachments, id: primary_key_type do |t| + t.string :name, null: false + t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type + t.references :blob, null: false, type: foreign_key_type + + if connection.supports_datetime_with_precision? + t.datetime :created_at, precision: 6, null: false + else + t.datetime :created_at, null: false + end + + t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + + create_table :active_storage_variant_records, id: primary_key_type do |t| + t.belongs_to :blob, null: false, index: false, type: foreign_key_type + t.string :variation_digest, null: false + + t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + def primary_and_foreign_key_types + config = Rails.configuration.generators + setting = config.options[config.orm][:primary_key_type] + primary_key_type = setting || :primary_key + foreign_key_type = setting || :bigint + [primary_key_type, foreign_key_type] + end +end diff --git a/db/migrate/20240224165704_create_action_text_tables.action_text.rb b/db/migrate/20240224165704_create_action_text_tables.action_text.rb new file mode 100644 index 0000000..1be48d7 --- /dev/null +++ b/db/migrate/20240224165704_create_action_text_tables.action_text.rb @@ -0,0 +1,26 @@ +# This migration comes from action_text (originally 20180528164100) +class CreateActionTextTables < ActiveRecord::Migration[6.0] + def change + # Use Active Record's configured type for primary and foreign keys + primary_key_type, foreign_key_type = primary_and_foreign_key_types + + create_table :action_text_rich_texts, id: primary_key_type do |t| + t.string :name, null: false + t.text :body, size: :long + t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type + + t.timestamps + + t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true + end + end + + private + def primary_and_foreign_key_types + config = Rails.configuration.generators + setting = config.options[config.orm][:primary_key_type] + primary_key_type = setting || :primary_key + foreign_key_type = setting || :bigint + [primary_key_type, foreign_key_type] + end +end diff --git a/db/migrate/20240224220515_create_tags.rb b/db/migrate/20240224220515_create_tags.rb new file mode 100644 index 0000000..7db0657 --- /dev/null +++ b/db/migrate/20240224220515_create_tags.rb @@ -0,0 +1,9 @@ +class CreateTags < ActiveRecord::Migration[7.1] + def change + create_table :tags do |t| + t.string :name, null: false, index: { unique: true } + + t.timestamps + end + end +end diff --git a/db/migrate/20240225070152_create_tag_references.rb b/db/migrate/20240225070152_create_tag_references.rb new file mode 100644 index 0000000..ba945a8 --- /dev/null +++ b/db/migrate/20240225070152_create_tag_references.rb @@ -0,0 +1,10 @@ +class CreateTagReferences < ActiveRecord::Migration[7.1] + def change + create_table :tag_references do |t| + t.references :tag, null: false, foreign_key: true + t.references :taggable, null: false, polymorphic: true + + t.timestamps + end + end +end diff --git a/db/migrate/20240225071927_create_searches.rb b/db/migrate/20240225071927_create_searches.rb new file mode 100644 index 0000000..a2a42e7 --- /dev/null +++ b/db/migrate/20240225071927_create_searches.rb @@ -0,0 +1,11 @@ +class CreateSearches < ActiveRecord::Migration[7.1] + def change + create_table :searches do |t| + t.string :name + t.string :body + t.references :user, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20240225100002_add_note_to_things.rb b/db/migrate/20240225100002_add_note_to_things.rb new file mode 100644 index 0000000..b0c0f40 --- /dev/null +++ b/db/migrate/20240225100002_add_note_to_things.rb @@ -0,0 +1,5 @@ +class AddNoteToThings < ActiveRecord::Migration[7.1] + def change + add_column :things, :note, :string + end +end diff --git a/db/migrate/20240226063134_add_uniqueness_index_search.rb b/db/migrate/20240226063134_add_uniqueness_index_search.rb new file mode 100644 index 0000000..77247df --- /dev/null +++ b/db/migrate/20240226063134_add_uniqueness_index_search.rb @@ -0,0 +1,8 @@ +class AddUniquenessIndexSearch < ActiveRecord::Migration[7.1] + def change + add_index :searches, :name, unique: true + add_index :searches, :body, unique: true + + add_index :things, :target, unique: true + end +end diff --git a/db/migrate/20240227085442_add_last_search_id_to_users.rb b/db/migrate/20240227085442_add_last_search_id_to_users.rb new file mode 100644 index 0000000..be58999 --- /dev/null +++ b/db/migrate/20240227085442_add_last_search_id_to_users.rb @@ -0,0 +1,5 @@ +class AddLastSearchIdToUsers < ActiveRecord::Migration[7.1] + def change + add_column :users, :last_search_id, :integer + end +end diff --git a/db/migrate/20240227145317_add_authors_to_thing.rb b/db/migrate/20240227145317_add_authors_to_thing.rb new file mode 100644 index 0000000..0c26b81 --- /dev/null +++ b/db/migrate/20240227145317_add_authors_to_thing.rb @@ -0,0 +1,6 @@ +class AddAuthorsToThing < ActiveRecord::Migration[7.1] + def change + add_column :things, :authors, :string, null: false + add_column :things, :editors, :boolean, default: false + end +end diff --git a/db/migrate/20240301154452_add_shared_to_searches.rb b/db/migrate/20240301154452_add_shared_to_searches.rb new file mode 100644 index 0000000..4950c23 --- /dev/null +++ b/db/migrate/20240301154452_add_shared_to_searches.rb @@ -0,0 +1,5 @@ +class AddSharedToSearches < ActiveRecord::Migration[7.1] + def change + add_column :searches, :shared, :boolean, default: false + end +end diff --git a/db/migrate/20240307220309_add_where_is_it_to_things.rb b/db/migrate/20240307220309_add_where_is_it_to_things.rb new file mode 100644 index 0000000..6d18307 --- /dev/null +++ b/db/migrate/20240307220309_add_where_is_it_to_things.rb @@ -0,0 +1,5 @@ +class AddWhereIsItToThings < ActiveRecord::Migration[7.1] + def change + add_column :things, :where_is_it, :string + end +end diff --git a/db/migrate/20240313133513_change_access_and_bought_at_to_date.rb b/db/migrate/20240313133513_change_access_and_bought_at_to_date.rb new file mode 100644 index 0000000..ea2f5bd --- /dev/null +++ b/db/migrate/20240313133513_change_access_and_bought_at_to_date.rb @@ -0,0 +1,6 @@ +class ChangeAccessAndBoughtAtToDate < ActiveRecord::Migration[7.1] + def change + change_column :things, :access, :date + change_column :things, :bought_at, :date + end +end |
