brittneybrinsfield / sequel-pro

Automatically exported from code.google.com/p/sequel-pro
Other
0 stars 0 forks source link

[REQ] Custom Default columns and indexes for New Table #1115

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be a welcome feature to allow us to edit the Create Table syntax that 
is used. As of right now I have to delete the index, change the 'id' column to 
what I want it to be, then add an index back in.

It need something like this:
CREATE TABLE `[input1]` (
  `id` varchar(35) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=[input2] DEFAULT CHARSET=[input];

Thanks for considering!
Jules

Original issue reported on code.google.com by giulioat...@gmail.com on 12 Jul 2011 at 10:21

GoogleCodeExporter commented 9 years ago
Good idea.
However I don't know if we need an interface for that or only allow the user to 
override a XML file with standard queries.

For now you can solve your problem by writing a custom Bundle.

Original comment by schlabbe...@gmail.com on 15 Jul 2011 at 2:41

GoogleCodeExporter commented 9 years ago
Is the current 'create table' available as a bundle? I've looked at some bundle 
examples and was lost... I don't know perl but have used tinkered with bash 
before. Would I do something like this?

# send query to Sequel Pro
cat <<SQL 
[create-table syntax here]
SQL

# execute the SQL statement
open "sequelpro://$SP_PROCESS_ID@passToDoc/ExecuteQuery"

Original comment by giulioat...@gmail.com on 17 Jul 2011 at 2:36

GoogleCodeExporter commented 9 years ago
Hi,

it would be possible to write a Bundle command to achieve that but I think a 
self-defined Query Favorite is easier here :)

Please:
- open the Query Editor view
- click at "Query Favorites" > "Edit Favorites…"
- at the left side click at the + button to add a new favorite
- name the new favorite to whatever "create tbl"
- make sure it's in the "Global" section (for change -> drag&drop)
- at the right side copy this command into the favorite syntax field

CREATE TABLE ``${0:tbl_name}`` (
    ``${1:id_fld}`` VARCHAR(35) NOT NULL,
    PRIMARY KEY (`$1`)
) ENGINE=${3:¦InnoDB¦MyISAM¦} DEFAULT CHARSET=${4:¦utf8¦latin1¦};

- click into "Tab Trigger" and type e.g. "ct"
- save it

Then you can simply to "ct" and press the TAB key ⇥ and the favorite will be 
inserted as dynamic snippet. Use the (SHIFT+)TAB keys to navigate through the 
different insertion points. This snippet makes usage of 'mirrored snippets', 
e.g. if you enter the name for the id field it will be changed in PRI KEY as 
well.

For more help look at http://www.sequelpro.com/docs/Query_Favorites

For a Bundle command with an user-definable interface for entering data please 
wait  ... I've to think about ;)

More general one could think about to allow to specify the default values for 
creating new fields in the Structure view.

Cheers,
--Hans

Original comment by bibiko@gmail.com on 17 Jul 2011 at 9:55

GoogleCodeExporter commented 9 years ago
bibiko, that is way cool. I never played around with that before. Your version 
allows for lots of specs, but is almost as much for me as just editing the 
default table. I've boiled it down to this, for my own needs:

CREATE TABLE ``${0:tbl_name}`` (
    `id` VARCHAR(35) NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Now I only have to enter the table name. Great! Thanks for pointing me in the 
right direction!

Original comment by giulioat...@gmail.com on 18 Jul 2011 at 12:24

GoogleCodeExporter commented 9 years ago
Nice Bibiko, but I think that it would be nice to have it easier. Like a "set 
this table as create table template" menu option. ;-) Or a by default disabled 
"overwrite create table template" bundle.

Original comment by mikebran...@gmail.com on 17 Apr 2012 at 7:52