Move DB dir

This commit is contained in:
2024-08-05 19:00:09 +10:00
parent 7e9121f9f9
commit 2e0ddcc888
46 changed files with 235 additions and 6 deletions

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :posts do
primary_key :id
column :name, :text, null: false, default: ""
column :content, :text, null: false
column :published_at, :timestamp
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
add_column :slug, :text, null: false
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
add_unique_constraint :slug
end
end
end

View File

@@ -0,0 +1,13 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :bookmarks do
primary_key :id
column :url, :text, null: false
column :name, :text, null: false
column :content, :text, null: false, default: ""
column :published_at, :timestamp
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :bookmarks do
add_column :slug, :text, null: false, unique: true
end
end
end

View File

@@ -0,0 +1,16 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :tags do
primary_key :id
column :label, :text, null: false, unique: true
column :slug, :text, null: false, unique: true
end
create_table :post_tags do
foreign_key :post_id, :posts, null: false
foreign_key :tag_id, :tags, null: false
end
end
end

View File

@@ -0,0 +1,11 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
drop_table :bookmarks
alter_table :posts do
add_column :url, :text
add_column :post_type, :text
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
set_column_allow_null :content
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
set_column_allow_null :name
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
add_column :syndication_sources, :json, default: "{}"
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
add_column :photos, :json, default: "[]", null: false
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
add_column :location, :text, default: nil
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table(:posts) do
set_column_type :syndication_sources, :jsonb
end
end
end

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :workouts do
primary_key :id
column :path, :text, null: false
column :distance, :float, null: false
column :published_at, :timestamp
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :workouts do
add_column :duration, :float, null: false
end
end
end

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :movies do
primary_key :id
column :title, :text, null: false
column :year, :integer
column :url, :text, null: false
end
end
end

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table(:auto_taggings) do
primary_key :id
column :title_contains, :text
column :body_contains, :text
foreign_key :tag_id, :tags, null: false
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table(:posts) do
add_column :cached_content, :text
end
end
end

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
require "que"
ROM::SQL.migration do
up do
Que.connection = self
Que.migrate!(version: 7)
end
down do
Que.connection = self
Que.migrate!(version: 0)
end
end

View File

@@ -0,0 +1,14 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :trips do
primary_key :id
column :name, :text, null: false
column :start_date, :date, null: false
column :end_date, :date, null: false
# column :latitude, :float, null: false
# column :longitude, :float, null: false
end
end
end

View File

@@ -0,0 +1,10 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :post_trips do
foreign_key :post_id, :posts, null: false
foreign_key :trip_id, :trips, null: false
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :trips do
add_column :subtitle, :text
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :movies do
add_column :watched_at, :date
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :movies do
add_column :imdb_id, :text
end
end
end

View File

@@ -0,0 +1,13 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :top_tracks do
column :artist, :text
column :name, :text
column :url, :text
column :mb_id, :text # musicbrainz.org ID
foreign_key :post_id, :posts, null: false, unique: true
end
end
end

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :podcasts do
primary_key :id
column :name, :text, null: false
column :url, :text, null: false
column :overcast_id, :text, null: false
end
end
end

View File

@@ -0,0 +1,10 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
add_column :book_status, :text, default: nil
add_column :book_author, :text, default: nil
end
end
end

View File

@@ -0,0 +1,24 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :webmentions do
primary_key :id
column :type, :text, null: false, default: ""
column :author_name, :text, null: false, default: ""
column :author_photo, :text, null: false, default: ""
column :author_url, :text, default: ""
column :published_at, :timestamp
column :content_html, :text, null: false, default: ""
column :content_text, :text, null: false, default: ""
column :source_url, :text, null: false, default: ""
column :target_url, :text, null: false, default: ""
foreign_key :post_id, :posts
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :trips do
add_column :summary, :text, default: nil
end
end
end

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :pages do
primary_key :id
column :name, :text, null: false
column :content, :text, null: false
column :slug, :text, null: false
column :published_at, :date
index :slug, unique: true
end
end
end

View File

@@ -0,0 +1,10 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :users do
uuid :id, primary_key: true
column :email, :text, null: false, unique: true
end
end
end

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :login_tokens do
primary_key :id
column :user_id, :uuid, null: false
column :token, :uuid, null: false
column :created_at, :timestamptz, default: Sequel.lit("now()")
end
end
end

View File

@@ -0,0 +1,17 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :podcast_scrobbles do
primary_key :id
column :overcast_id, :text
column :podcast_name, :text
column :title, :text
column :url, :text
column :enclosure_url, :text
column :listened_at, :date
index :overcast_id
end
end
end

View File

@@ -0,0 +1,11 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :pages do
add_column :main_menu, :boolean, default: false
add_column :light_colour, :text
add_column :dark_colour, :text
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table(:movies) do
add_column :rating, :float, default: 0.0
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :webmentions do
add_column :retrieval_attempts, :integer, default: 0
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :webmentions do
add_column :last_checked_at, :timestamp
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
add_column :is_read, :bool, default: false
end
end
end

View File

@@ -0,0 +1,37 @@
# frozen_string_literal: true
ROM::SQL.migration do
up do
execute <<-SQL
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = (now() at time zone 'utc');
RETURN NEW;
END;
$$ language 'plpgsql';
SQL
alter_table :pages do
add_column :updated_at, :timestamp
end
run <<-SQL
CREATE TRIGGER update_pages_updated_at BEFORE UPDATE
ON pages FOR EACH ROW EXECUTE PROCEDURE
update_updated_at_column();
SQL
end
down do
execute("DROP FUNCTION IF EXISTS update_updated_at_column();")
run <<-SQL
DROP TRIGGER IF EXISTS update_pages_updated_at ON pages;
SQL
alter_table :pages do
drop_column :updated_at
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
add_column :programming_language, :text
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
add_column :commentable, :boolean, default: false
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
add_column :in_reply_to, :text
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
alter_table :posts do
add_column :emoji, :text
end
end
end

View File

@@ -0,0 +1,14 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :reactions do
primary_key :id
foreign_key :post_id, :posts, null: false
column :visitor_identifier, :text, null: false
index :post_id
unique [:post_id, :visitor_identifier]
end
end
end

View File

@@ -0,0 +1,13 @@
# frozen_string_literal: true
ROM::SQL.migration do
change do
create_table :highlights do
primary_key :id
foreign_key :post_id, :posts, null: false
column :text, :text, null: false
index :post_id
end
end
end

1116
config/db/structure.sql Normal file

File diff suppressed because it is too large Load Diff